Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/01/2009, 13:00
daviteN
 
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>