Ver Mensaje Individual
  #3 (permalink)  
Antiguo 29/02/2012, 09:55
esaenz22
(Desactivado)
 
Fecha de Ingreso: abril-2008
Mensajes: 787
Antigüedad: 16 años
Puntos: 7
Respuesta: error al subir multiples imagenes

gracias por tu respuesta repara2. las rutas para almacenar las imagenes estan bien.

la carpeta "productos/" guardo las imagenes de tamaño 252 x 252 y para la galeria las guardo en la carpeta "productos/thumbnail/" de tamaño 72 x 72.

lo estoy probando localmente y me da el mismo problema.

saludos.

Código PHP:
Ver original
  1. if(isset($_FILES))
  2. {
  3.     $idproducto = mysql_insert_id();
  4.    
  5.     foreach($_FILES as $files => $file)
  6.     {
  7.         if(isset($file['name']) && !$file['error'] && $file['size']!=0)
  8.         {
  9.            
  10.             $f=1;
  11.             while($f)
  12.             {
  13.                 $nombre = 'productos/'.$f.$file['name'];
  14.                 $nombre_imagen = $f.$file['name'];
  15.                 clearstatcache();
  16.                
  17.                 if (file_exists($nombre))
  18.                     $f++;
  19.                 else
  20.                     $f=0;
  21.             }
  22.                
  23.                 // we instanciate the class for each element of $file
  24.                 $handle = new Upload($file);
  25.                
  26.                 // then we check if the file has been uploaded properly
  27.                 // in its *temporary* location in the server (often, it is /tmp)
  28.                 if ($handle->uploaded)
  29.                 {
  30.                     $handle->image_resize            = true;
  31.                     $handle->image_ratio_y           = true;
  32.                     $handle->image_x                 = 252;
  33.                     $handle->Process('productos/');
  34.                    
  35.                     // creo una variable $nombre_imagen para enviar los nombres de las imagenes.
  36.                     $nombre_imagen = $handle->file_dst_name;
  37.                     $handle->clean();                          
  38.                 }
  39.                 else
  40.                 {
  41.                     // if we're here, the upload file failed for some reasons
  42.                     // i.e. the server didn't receive the file
  43.                     echo '  file not uploaded on the server';
  44.                     echo '  Error: ' . $handle->error . '';
  45.                 }
  46.                
  47.                 // (imagen thb para las galerias)
  48.                 $imagen_thb = new Upload($file);
  49.        
  50.                 // then we check if the file has been uploaded properly
  51.                 // in its *temporary* location in the server (often, it is /tmp)
  52.                 if ($imagen_thb->uploaded)
  53.                 {
  54.                     $imagen_thb->image_resize         = true;
  55.                     $imagen_thb->image_ratio_fill     = true;      
  56.                     $imagen_thb->image_x              = 74;
  57.                     $imagen_thb->image_y              = 74;            
  58.                     $imagen_thb->Process('productos/thumbnail/');                      
  59.                     $foto_imagen_thb = $imagen_thb->file_dst_name;
  60.                    
  61.                 }
  62.                
  63.                 // pregunto si la variable a ingresar esta o no vacia.
  64.                 if($nombre_imagen!="" && $foto_imagen_thb!="")
  65.                 {
  66.                     // hacemos el insert para la tabla puente que en este caso es galeria_producto
  67.                     $sql_galeria_fotos  = "INSERT INTO galeria_producto(idproducto,imagen,imagen_thb)VALUES('$idproducto','$nombre_imagen','$foto_imagen_thb')";
  68.                     echo $sql_galeria_fotos;
  69.                     echo "<br />";
  70.                     query($sql_galeria_fotos,$cn) or die(mysql_error());               
  71.                    
  72.                     if($_POST['pagina']!="")
  73.                     {
  74.                         $pagina = $_POST['pagina'];
  75.                         $a = "&pagina=$pagina";
  76.                     }          
  77.                    
  78.                 }
  79.                    
  80.                     //header("Location:index.php?ok=1$a");                     
  81.                
  82.  
  83.         }
  84.        
  85.     } // termina el bucle foreach.
  86.    
  87.    
  88. }

Última edición por esaenz22; 29/02/2012 a las 10:12 Razón: correccion del post.