Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/01/2010, 12:00
Avatar de Jandor
Jandor
 
Fecha de Ingreso: septiembre-2009
Mensajes: 71
Antigüedad: 14 años, 7 meses
Puntos: 1
Exclamación Ayuda con GD para imagenes

Hola amigos del foro, tnego este problema, esoty utilizando la libreria GD para poder redimensionar imagenes que el usuario sube a mi servidor. E buscado por todos lados y hasta en ette foro mi problema y efectivamente he encntrado respuestas, pero aun asi no me sirve, ya que a pesar de realizar numerosos intento no logro que la imagen se almacene en mi servidor....

dejo codigo para mayor referencia:

if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';

$img = $_FILES['Filedata']['name'];
$ext = substr(strrev($img),0,4);
$extC = strrev($ext);


if($extC == ".jpg" || $extC == ".gif" || $extC == ".png"){

$logo = "logo".$extC;


$targetFile = str_replace('//','/',$targetPath) . $logo;

//---------------------------------------------------------------------------------------------------------
$anchura=110;
$hmax=80;
$nombre=basename($tempFile); //Nombre temporal
$datos = getimagesize($nombre);
if($datos[2]==1){$imgT = @imagecreatefromgif($nombre);}
if($datos[2]==2){$imgT = @imagecreatefromjpeg($nombre);}
if($datos[2]==3){$imgT = @imagecreatefrompng($nombre);}
$ratio = ($datos[0] / $anchura);
$altura = ($datos[1] / $ratio);

if($altura>$hmax){
$anchura2 = $hmax*$anchura/$altura;
$altura = $hmax;
$anchura = $anchura2;
}

$thumb = imagecreatetruecolor($anchura,$altura);
imagecopyresampled($thumb, $imgT, 0, 0, 0, 0, $anchura, $altura, $datos[0], $datos[1]);
if($datos[2]==1){header("Content-type: image/gif"); imagegif($thumb, $targetFile, 100); }
if($datos[2]==2){header("Content-type: image/jpeg"); imagejpeg($thumb, $targetFile, 100);}
if($datos[2]==3){header("Content-type: image/png"); imagepng($thumb, $targetFile, 100); }
imagedestroy($thumb);
//---------------------------------------------------------------------------------------------------------

//move_uploaded_file($tempFile,$targetFile);
echo "1";
}
}

Si alguien se da cuenta de mi error me gustaria saberlo ya que esto me urge.... gracias de ante mano....

Ah y si por las dudas si tengo instalado la libreria gd en mi php, y es la GD 2