Foros del Web » Programando para Internet » PHP »

imagejpeg con verion php 5.1.6

Estas en el tema de imagejpeg con verion php 5.1.6 en el foro de PHP en Foros del Web. Buenas tardes a todos, Tengo una clase que gestiona ficheros y tambien hace tratamiento de imagenes (basico). Me esta funcionando en todas aplicaciones en mi ...
  #1 (permalink)  
Antiguo 17/03/2009, 15:31
 
Fecha de Ingreso: septiembre-2006
Mensajes: 349
Antigüedad: 17 años, 7 meses
Puntos: 0
imagejpeg con verion php 5.1.6

Buenas tardes a todos,

Tengo una clase que gestiona ficheros y tambien hace tratamiento de imagenes (basico). Me esta funcionando en todas aplicaciones en mi servidor que tiene php 5.2.4.

Pero tengo una aplicacion alojada en servidor que no es mio y alli la version de php es 5.1.6. ME da error funcion imagejpeg

Código PHP:
Warningimagejpeg() [function.imagejpeg]: Unable to open '/crm/eventos/content/picture/res/137_15.jpg' for writing in .......FileMng.php on line 961 
He probado aplicar siguentes soluciones

Código PHP:
case "jpeg":
                 
chmod($folder0777); 
                 
header("Content-type: image/jpeg"); 
                 
imagejpeg($temp$folder.$this -> name);

                 
imagedestroy($temp); 

Código PHP:
case "jpeg":
                 
chmod($folder.$this -> name0777); 
                
ini_set("safe_mode","Off");
                 
imagejpeg($temp$folder.$this -> name);
ini_set("safe_mode","On");
                 
imagedestroy($temp); 

AL intentar utilizar fopen() me dice que no existe tal fichero. O sea que ni lo intenta crear.

Adjunto el codigo de funcion resize de mi clase. Si hace falta pongo todo el codigo de la clase. Seguro que tiene fallos, pero el echo es que me funciona con PHP 5.2.4 y no con 5.1.6

Código PHP:
    public function resize($folder ""$w ""$h ""){

        

        if(!
$w){

            
$w WIDTH_MAX;

        }

        if(!
$h){

            
$h HEIGHT_MAX;

        }

         

         if(!
$folder){

            
$folder $this -> getResUrl();

         }

         

         if (!
function_exists("imagecreate"))

         {

            echo 
"Error: GD Library is not available.";

             return 
false;

         }



        if(
$this -> width $w || $this -> height $h) {

        

            if(
$dif 1){

                
/* height < width */

                
$newWidth $w;

                
$newHeight $this -> height /($this -> width $w);

            }

                    

            
/* height > width */

            
if($dif 1){

                
$newHeight=$h;

                
$newWidth=$this -> width /($this -> height $h);

            }    

            

            
/* height = width */

            
if($dif == 1){

                
$diference $this -> width $w;

                
$newWidth $w;

                
$newHeight $this -> height $diference;

            }

    

        } else {

            
$newWidth $w;

            
$newHeight $h;

        }

        

    

      
/* create an empty image with requested height/width */

     
$temp imagecreatetruecolor($newWidth$newHeight);

    

    
/* Create a new image from file or URL */
     
     
switch($this -> ext){

         case 
"gif":

         
$image imagecreatefromgif($this -> path);

         break;

         case 
"jpg":

         
$image imagecreatefromjpeg($this -> path);

         break;

         case 
"jpeg":
        
         
$image imagecreatefromjpeg($this -> path);

         break;

         case 
"png":

         
$image imagecreatefrompng($this -> path);

         break;

     }

    if(!
imagecopyresampled($temp$image0000$newWidth$newHeight$this -> width$this -> height)){

         
trigger_error(IMAGECOPYRESAMPLED_FAIL);

         return 
false;

    } else {



    
/* Create a new image from file or URL */

        

         
switch($this -> ext){

             case 
"gif":

                 
imagegif($temp$folder.$this -> name);

                 
imagedestroy($temp);

                 break;

             case 
"jpg":
            
                
imagejpeg($temp$folder.$this -> name100);
            
                 
imagedestroy($temp);

             break;

             case 
"jpeg":
                 
chmod($folder0777); 
                 
header("Content-type: image/jpeg"); 
                 
imagejpeg($temp$folder.$this -> name);

                 
imagedestroy($temp);

             break;

             case 
"png":

                 
imagepng($temp$folder.$this -> name);

                 
imagedestroy($temp);

             break;

         }

      } 




Gracias a todos!
  #2 (permalink)  
Antiguo 17/03/2009, 16:18
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: imagejpeg con verion php 5.1.6

Si tienes safe_mode en On, vas a tener que cambiar los permisos de la carpeta manualmente, ya que usando chmod no se va a alterar los permisos de la carpeta.

Saludos.
  #3 (permalink)  
Antiguo 18/03/2009, 12:33
 
Fecha de Ingreso: septiembre-2006
Mensajes: 349
Antigüedad: 17 años, 7 meses
Puntos: 0
Respuesta: imagejpeg con verion php 5.1.6

Safe mode tengo en On. Pero todas las carpetas tienen permiso 0777 (lo aplique de forma manual). Revisado muchas veces.
Necesito una solucion, alquien se ha encontrado con algun problema parecido y lo ha resuelto?

Gracias a todos por adelantado!
  #4 (permalink)  
Antiguo 18/03/2009, 14:24
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: imagejpeg con verion php 5.1.6

Revisa también que el owner de la carpeta sea el mismo o al menos pertenezca al mismo grupo de usuarios bajo el que se esta ejecutando PHP.

Saludos.
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 22:51.