Foros del Web » Programando para Internet » PHP »

[Ayuda] Upload Imgen.

Estas en el tema de [Ayuda] Upload Imgen. en el foro de PHP en Foros del Web. Hola , yo uso este upload.php para subir mis fotos a mi ftp. pero el problema es que si pongo imanes muy grandes. me salta ...
  #1 (permalink)  
Antiguo 25/01/2009, 13:00
 
Fecha de Ingreso: enero-2007
Mensajes: 56
Antigüedad: 17 años, 3 meses
Puntos: 0
[Ayuda] Upload Imgen.

Hola , yo uso este upload.php para subir mis fotos a mi ftp. pero el problema es que si pongo imanes muy grandes. me salta este error "Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13184 bytes) in /home/sg000242/public_html/fotos/upload.php on line 49"

Este es el upload.php que uso:
Código PHP:
<?php
   
  
# DETAILS
  
$UPLOAD_DIR 'Alternative/';    # UPLOAD DIRECTORY
  
$max_width  '499';            # WIDTH TO RESIZE IMAGES ABOVE IT
  
$max_height '374';            # HEIGHT TO RESIZE IMAGES ABOVE IT
   
  # DETECT UPLOAD PRESS
  
if(isset($_POST['upload'])){
    
# ADD HERE THE CODE FOR ANY OTHER FIELDS YOU MIGHT HAVE
     
    # GET UPLOADED FILES
    
$photo $HTTP_POST_FILES['photo'];
    foreach(
$photo['name'] as $file_id => $file){
      
# IF FILE IS IMAGE
      
if($file != NULL && (strstr($file'.jpg') || strstr($file'.png') || strstr($file'.gif'))){
        
# REPLACE QUOTES
        
$file str_replace("'""`"$file);
        
$file str_replace('"''`'$file);
        
# COMPOSE URL
        
$url $UPLOAD_DIR.$file;
        
# COPY FILE TO URL
        
if(copy($photo['tmp_name'][$file_id],$url)){
          
# DELETE TMP FILE
          
unlink($photo['tmp_name'][$file_id]);
          
# GET IMAGE DETAILS
          
$data GetImageSize($url);
          
$mime $data['mime'];
          
# IF IMAGE IS BIGGER THEN MAX VALUES
          
if (($data[0] > $max_width) or ($height $max_height)) {
            
# IF WIDTH IS BIGGER
            
if ($data[0] > $max_width) {
              
$width $max_width;
              
$height $data[1]/($data[0]/$width);
            }
            
# IF HEIGHT IS BIGGER AFTER WIDTH BASED RESIZE
            
if ($height $max_height) {
              
$height $max_height;
              
$width $data[0]/($data[1]/$height);
            }
            
# CRATE NEW IMAGE
            
$frame ImageCreateTrueColor($width$height);
            
# CRATE FILE IMAGE
            
if ($mime == 'image/gif') {
              
$im ImageCreateFromGIF($url);
            } else if (
$mime == 'image/png') {
              
$im ImageCreateFromPNG($url);
            } else if (
$mime == 'image/jpeg') {
              
$im ImageCreateFromJPEG($url);
            }
            
# RESIZE
            
imagecopyresized ($frame$im0000$width$height$data[0], $data[1]);
            
# WRITE RESIZED IMAGE
            
imagejpeg($frame,$url,80);
            
imagedestroy($frame);
            
imagedestroy($im);
             
            
# ADD HERE THE CODE THAT INSERTS DATA INTO A DATABASE IF YOU WISH
            # FILE NAME VARIABLE IS  $file
          
}
        }
      }
    }
  }
?>
<form action='' method='post' enctype='multipart/form-data'>
PHOTO 1: <input type=file name=photo[]><br>
PHOTO 2: <input type=file name=photo[]><br>
PHOTO 3: <input type=file name=photo[]><br>
PHOTO 4: <input type=file name=photo[]><br>
PHOTO 5: <input type=file name=photo[]><p>
<input type=submit name=upload value=Upload>
</form>
  #2 (permalink)  
Antiguo 25/01/2009, 14:58
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: [Ayuda] Upload Imgen.

PHP te esta diciendo que se le acabo la memoria, trata de depurar tu codigo y hacerlo mas optimo. Y si aun asi todavia te muestra que no hay suficiente memoria, intenta usando ini_set.

ini_set('memory_limit', '64M');
  #3 (permalink)  
Antiguo 25/01/2009, 16:21
 
Fecha de Ingreso: enero-2007
Mensajes: 56
Antigüedad: 17 años, 3 meses
Puntos: 0
Respuesta: [Ayuda] Upload Imgen.

mira no tengo ni idea como optimizarlo... yo lo sake de una web al upload.php , y prove agregando lo que me pasaste pero pasa lo mismo... osea la foto me la sube pero no me la ahica al tamaño que marca ahi... me la sube en el tamaño original.
  #4 (permalink)  
Antiguo 25/01/2009, 16:28
 
Fecha de Ingreso: enero-2007
Mensajes: 56
Antigüedad: 17 años, 3 meses
Puntos: 0
Respuesta: [Ayuda] Upload Imgen.

ya esta solucionado! habia puesto mal lo que me pasaste lo puse bien y listo... Muchas Gracias Amigo.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:34.