#1 PHP: Upload y miniatura
Hola, necesito hacer un upload de una imagen y luego hacer
una copia en miniatura de la imagen que subí.
El sector del código que se encarga de subir funciona perfectamente,
pero no puedo conseguir que me haga la copia en miniatura de la imagen
que subí.
El código es este:
Muchas Gracias!!!
una copia en miniatura de la imagen que subí.
El sector del código que se encarga de subir funciona perfectamente,
pero no puedo conseguir que me haga la copia en miniatura de la imagen
que subí.
El código es este:
<?php
if ($_GET["action"] == "upload") { // lo estoy mandando desde Flash...
$archivo = $_FILES["Filedata"]['name'];
$prefijo = substr(md5(uniqid(rand())),0,6);
if ($archivo != "") {
$destino = "files/".$prefijo."_".$archivo;
copy($_FILES['Filedata']['tmp_name'], $destino);
}
} // HASTA ACÁ FUNCIONA BIEN...
/*
Pero a partir de acá, este script no genera la imagen miniatura
en la carpeta 'thumbs'
*/
$filenameA = $destino.$archivo;
$dirdestA = '/home/mi_user_name/public_html/Sharer/UNI/thumbs/';
$qualA= 100;
/************************************************** ******/
$thumb = imagecreatetruecolor(150, 120);
$source = imagecreatefromjpeg($filenameA);
$copia = imagecopyresized($thumb, // imagen creada
$source, // imagen fuente
0, //
0, //
0, // _x
0, // _y
150, //
120, //
150, // nuevo Ancho
120); // nuevo Alto
mt_srand (time());
$numero_aleatorio = mt_rand(999999999999,0);
$absoluto = abs($numero_aleatorio);
$nombre_imagen = $filenameA.$absoluto; // le agrego una cadena aletoria, por las dudas...
$dirdestA = '/home/mi_user_name/public_html/Sharer/UNI/thumbs/';
/* ESTA ES LA CARPETA DESTINO CON TODOS LOS PERMISOS, IGUAL QUE LA CARPETA FILES.*/
$salva=$dirdestA.$nombre_imagen;
imagejpeg($thumb, $salva.'.jpg', 100);
imagedestroy($source);
imagedestroy($thumb);
?>
if ($_GET["action"] == "upload") { // lo estoy mandando desde Flash...
$archivo = $_FILES["Filedata"]['name'];
$prefijo = substr(md5(uniqid(rand())),0,6);
if ($archivo != "") {
$destino = "files/".$prefijo."_".$archivo;
copy($_FILES['Filedata']['tmp_name'], $destino);
}
} // HASTA ACÁ FUNCIONA BIEN...
/*
Pero a partir de acá, este script no genera la imagen miniatura
en la carpeta 'thumbs'
*/
$filenameA = $destino.$archivo;
$dirdestA = '/home/mi_user_name/public_html/Sharer/UNI/thumbs/';
$qualA= 100;
/************************************************** ******/
$thumb = imagecreatetruecolor(150, 120);
$source = imagecreatefromjpeg($filenameA);
$copia = imagecopyresized($thumb, // imagen creada
$source, // imagen fuente
0, //
0, //
0, // _x
0, // _y
150, //
120, //
150, // nuevo Ancho
120); // nuevo Alto
mt_srand (time());
$numero_aleatorio = mt_rand(999999999999,0);
$absoluto = abs($numero_aleatorio);
$nombre_imagen = $filenameA.$absoluto; // le agrego una cadena aletoria, por las dudas...
$dirdestA = '/home/mi_user_name/public_html/Sharer/UNI/thumbs/';
/* ESTA ES LA CARPETA DESTINO CON TODOS LOS PERMISOS, IGUAL QUE LA CARPETA FILES.*/
$salva=$dirdestA.$nombre_imagen;
imagejpeg($thumb, $salva.'.jpg', 100);
imagedestroy($source);
imagedestroy($thumb);
?>
Muchas Gracias!!!
0