Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/08/2010, 11:38
mcswebsis
 
Fecha de Ingreso: diciembre-2007
Mensajes: 42
Antigüedad: 16 años, 4 meses
Puntos: 0
problemas con serialize

que tal, tengo el siguiente problema

necesito guardar multiples imagenes para un sistema de noticias, hasta ahorita ya puedo guardar las referencias de los nombres de los archivos en la base de datos con un array.


el problema comienza cuando tengo que utilizar la funcion serialize (en realidad no se si la estoy usando bien).

les pongo el codigo:

Código PHP:
$files = array();
    foreach (
$_FILES['my_field'] as $k => $l) {
        foreach (
$l as $i => $v) {
            if (!
array_key_exists($i$files))
                
$files[$i] = array();
            
$files[$i][$k] = $v;
        }
    }
    
// now we can loop through $files, and feed each element to the class
    
foreach ($files as $file) {
        
// we instanciate the class for each element of $file
        
$handle = new Upload($file);
        
// then we check if the file has been uploaded properly
        // in its *temporary* location in the server (often, it is /tmp)
        
if ($handle->uploaded) {
            
// now, we start the upload 'process'. That is, to copy the uploaded file
            // from its temporary location to the wanted location
            // It could be something like $handle->Process('/home/www/my_uploads/');
            
$handle->Process($dir_dest);
            
// we check if everything went OK
            
if ($handle->processed) {
                
// everything was fine !
                
echo '<fieldset>';
                echo 
'  <legend>file uploaded with success</legend>';
                echo 
'  <p>' round(filesize($handle->file_dst_pathname)/256)/'KB</p>';
                echo 
'  link to the file just uploaded: <a href="'.$dir_pics.'/' $handle->file_dst_name '">' $handle->file_dst_name '</a>';
                echo 
'</fieldset>';
            } else {
                
// one error occured
                
echo '<fieldset>';
                echo 
'  <legend>file not uploaded to the wanted location</legend>';
                echo 
'  Error: ' $handle->error '';
                echo 
'</fieldset>';
            }

        } else {
            
// if we're here, the upload file failed for some reasons
            // i.e. the server didn't receive the file
            
echo '<fieldset>';
            echo 
'  <legend>file not uploaded on the server</legend>';
            echo 
'  Error: ' $handle->error '';
            echo 
'</fieldset>';
        }
    } 
Código PHP:
 <?php $valor=serialize($files); ?>
                    <input type="hidden" size="20" name="txtImage" value="<?php echo $valor?>" />
Código PHP:
mysql_query("INSERT INTO noticias (fecha,titulo,contenido,imagen)
        
        VALUES ('$sFecha','{$_POST['titulo']}','{$_POST['contenido']}','$txtImage')"
,$link); 



al querer mostrar la imagen utilizo:


Código PHP:
<img src="controlpanel/imagen_prueba/" alt="imagen no disponible" width="97" align="middle" height="111"/> 

aqui el problema tambien es como mostrar la primer imagen que inserte en el arreglo que esta en la carpeta imagen_prueba.


Espero puedan ayudarme.

Saludos cordiales