Foros del Web » Programando para Internet » PHP »

Error al subir imagen

Estas en el tema de Error al subir imagen en el foro de PHP en Foros del Web. Al elegir la imagen desde examinar, la imagen la guarda 3 veces en una carpeta tmp y me genera un nombre random para cada una, ...
  #1 (permalink)  
Antiguo 08/03/2007, 10:42
Avatar de maxi_lance  
Fecha de Ingreso: julio-2006
Ubicación: Capital Federal
Mensajes: 220
Antigüedad: 17 años, 9 meses
Puntos: 2
Error al subir imagen

Al elegir la imagen desde examinar, la imagen la guarda 3 veces en una carpeta tmp y me genera un nombre random para cada una, con diferentes tamaños. Pero me tira este error y no logro entenderlo. A ver si pueden darme una mano, gracias

Error:
Código PHP:
WarningDivision by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 178

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 179

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 180

Warning
getimagesize(../img/tmp/26008.jpg): failed to open streamNo such file or directory in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 290

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 178

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 179

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 180

Warning
getimagesize(../img/tmp/26008_medium.jpg): failed to open streamNo such file or directory in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 290

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 178

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 179

Warning
Division by zero in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 180

Warning
getimagesize(../img/tmp/26008_orig.jpg): failed to open streamNo such file or directory in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 290 
y el hft_image.php en conflicto es: desde la linea 178 a la 300, donde figura el error

Código PHP:
    if($desired_width != "*"$mult_x $desired_width $this->image_original_width;        
                    if(
$desired_height != "*"$mult_y $desired_height $this->image_original_height;                
                    
$ratio $this->image_original_width $this->image_original_height;

                    if(
$desired_width == "*"){
                        
$new_height $desired_height;
                        
$new_width $ratio $desired_height;
                    }elseif(
$desired_height == "*"){
                        
$new_height $desired_width $ratio;
                        
$new_width =  $desired_width;

                    }else{
                        if(
$mode=="-"){
                                if( 
$this->image_original_height $mult_x $desired_height ){
                                
//image must be smaller than given $desired_ region
                                //test which multiplier gives us best result

                                    //$mult_x does the job
                                    
$new_width $desired_width;
                                    
$new_height $this->image_original_height $mult_x;
                                }else{
                                    
//$mult_y does the job
                                    
$new_width $this->image_original_width $mult_y;
                                    
$new_height $desired_height;
                                }

                        }else{
                            
//mode == "+"
                            // cover the region
                            //image must be bigger than given $desired_ region
                            //test which multiplier gives us best result
                            
if( $this->image_original_height $mult_x $desired_height ){
                                
//$mult_x does the job
                                
$new_width $desired_width;
                                
$new_height $this->image_original_height $mult_x;
                            }else{
                                
//$mult_y does the job
                                
$new_width $this->image_original_width $mult_y;
                                
$new_height $desired_height;
                            }

                        }
                    }
                break;

                case 
'0':
                    
//fit the region exactly.
                    
if($desired_width == "*"$desired_width $this->image_original_width;        
                    if(
$desired_height == "*"$desired_height $this->image_original_height;    
                    
$new_width $desired_width;
                    
$new_height $desired_height;
                    
                break;
                default: 
                    
$q->exec('DELETE FROM sites WHERE id_sites = '.$lid);
                    die(
'Image type not valid.');
                    
//$this->error($ERR["UNKNOWN_RESIZE_MODE"]."  $mode");
                
break;
            }
            
            
// OK here we have $new_width _height
            //create destination image checking for GD2 functions:
            
if( $this->use_gd2 ){
                if( 
function_exists("imagecreatetruecolor")){
                
                    
$this->image_resized imagecreatetruecolor($new_width$new_height) or $this->error($ERR["GD2_NOT_CREATED"]);
                }else {
                    
$this->error($ERR["GD2_UNAVALABLE"]." ImageCreateTruecolor()");
                }
            } else {
            
            
                
$this->image_resized imagecreate($new_width$new_height) or $q->exec('DELETE FROM sites WHERE id_sites = '.$lid);
                    die(
'Image type not valid.');//$this->error($ERR["IMG_NOT_CREATED"]);
            
}

            
//Resize
            
if( $this->use_gd2 ){

                if( 
function_exists("imagecopyresampled")){
                    
$res imagecopyresampled($this->image_resized
                                              
$this->image_original
                                              
00,  //dest coord
                                              
00,            //source coord
                                              
$new_width$new_height//dest sizes
                                              
$this->image_original_width$this->image_original_height // src sizes
                                            
) or $this->error($ERR["GD2_NOT_RESIZED"]); 

                }else {
                    
$this->error($ERR["GD2_UNAVALABLE"]." ImageCopyResampled()");
                }
            } else {
            
                
$res imagecopyresized($this->image_resized
                                          
$this->image_original
                                          
00,  //dest coord
                                          
00,            //source coord
                                          
$new_width$new_height//dest sizes
                                          
$this->image_original_width$this->image_original_height // src sizes
                                        
) or $this->error($ERR["IMG_NOT_RESIZED"]); 
            }

        }
        
        function 
output_original($destination_file$image_type="JPG") { 
            return 
_output_image($destination_file$image_type$this->image_original); 
        } 
        
        function 
output_resized($destination_file$image_type="JPG") { 
            global 
$lid;
            
$res $this->_output_image($destination_file$image_type$this->image_resized); 
            if(
trim($destination_file)){ 
                
$sz=getimagesize($destination_file); 
                
$this->file_resized $destination_file
                
$this->image_resized_width $sz[0]; 
                
$this->image_resized_height $sz[1]; 
                
$this->image_resized_type_code=$sz[2]; 
                
$this->image_resized_html_sizes=$sz[3]; 
                switch(
$this->image_resized_html_sizes){ 
                    case 
0
                        
$this->image_resized_type_abbr "GIF"
                    break; 
                    case 
1
                        
$this->image_resized_type_abbr "JPG"
                    break; 
                    case 
2
  #2 (permalink)  
Antiguo 08/03/2007, 11:12
Avatar de mauled  
Fecha de Ingreso: marzo-2005
Ubicación: Cd. de México.
Mensajes: 3.001
Antigüedad: 19 años, 1 mes
Puntos: 33
De acuerdo Re: Error al subir imagen

Verifica que tus variables $this->image_original_width y $this->image_original_height esten correctamente inicializadas.

Saludillos.
  #3 (permalink)  
Antiguo 08/03/2007, 11:59
Avatar de maxi_lance  
Fecha de Ingreso: julio-2006
Ubicación: Capital Federal
Mensajes: 220
Antigüedad: 17 años, 9 meses
Puntos: 2
Re: Error al subir imagen

las tenia inicializadas en 0, cambie por 1 y ahora no me tira error.
El error que sigue tirando es:
Código PHP:
Warninggetimagesize(../img/tmp/18226.jpg): failed to open streamNo such file or directory in c:archivos de programaeasyphp1-8wwwpassionadmininchft_image.php on line 292 
y esa parte en el hft_image.php es:
Código PHP:
function output_original($destination_file$image_type="JPG") { 
            return 
_output_image($destination_file$image_type$this->image_original); 
        } 
        
        function 
output_resized($destination_file$image_type="JPG") { 
            global 
$lid;
            
$res $this->_output_image($destination_file$image_type$this->image_resized); 
            if(
trim($destination_file)){ 
                
$sz=getimagesize($destination_file); 
                
$this->file_resized $destination_file
                
$this->image_resized_width $sz[0]; 
                
$this->image_resized_height $sz[1]; 
                
$this->image_resized_type_code=$sz[2]; 
                
$this->image_resized_html_sizes=$sz[3]; 
                switch(
$this->image_resized_html_sizes){ 
                    case 
0
                        
$this->image_resized_type_abbr "GIF"
                    break; 
                    case 
1
                        
$this->image_resized_type_abbr "JPG"
                    break; 
                    case 
2
                        
$this->image_resized_type_abbr "PNG"
                    break; 
                    case 
3
                        
$this->image_resized_type_abbr "SWF"
                    break; 
                    default: 
                        
$this->image_resized_type_abbr "UNKNOWN"
                    break; 
                } 
                 
            } 
            return 
$res
        } 

        function 
_output_image($destination_file$image_type$image){ 
            global 
$lid;
            global 
$ERR
            
$destination_file trim($destination_file); 
            
$res false
            if(
$image){ 
                switch(
$image_type) { 
                    case 
'JPEG'
                    case 
'JPG'
                     
                        
$res ImageJpeg($image$destination_file$this->jpeg_quality); 
                    break; 
                    case 
'PNG'
                        
$res Imagepng($image$destination_file); 
                    break; 
                    default: 
                        
$this->error($ERR["UNKNOWN_OUTPUT_FORMAT"]." $image_type"); 
                    break; 
             
                } 
            }else{ 
                
$this->error($ERR["NO_IMAGE_FOR_OUTPUT"]); 
            } 
            if(!
$res$this->error($ERR["UNABLE_TO_OUTPUT"]." $destination_file"); 
            return 
$res
        } 
Antes que nada te agradezco por la respuesta,
  #4 (permalink)  
Antiguo 08/03/2007, 13:49
Avatar de maxi_lance  
Fecha de Ingreso: julio-2006
Ubicación: Capital Federal
Mensajes: 220
Antigüedad: 17 años, 9 meses
Puntos: 2
Re: Error al subir imagen

perdon por las insistencia pero sigo intentando arreglar en error y no me sale. Si hay puede darme una mano, encantado. De todas maneras gracias por leerlo.
  #5 (permalink)  
Antiguo 08/03/2007, 13:54
Avatar de mauled  
Fecha de Ingreso: marzo-2005
Ubicación: Cd. de México.
Mensajes: 3.001
Antigüedad: 19 años, 1 mes
Puntos: 33
Re: Error al subir imagen

Pues como el error te lo indica, no puede acceder a tu imagen, esto puede ser porque la ruta esta mal o bien no tienes lo permisos para acceder a la carpeta. Checate estos dos puntos.

Saludillos.
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 08:06.