aca hay un codigo que uso en un panel de control que realize, que sube la imagen y genera un thumbnail en otra carpeta, yo lo habia puesto asi...
me gustaria saber si es correcto, y si no es correcto que modificacion hacer para que pueda funcionar, o si directamente no funciona y que busque otra alternativa...
Código PHP:
$news = QuoteSmart($news);
$title = QuoteSmart($title);
$name = QuoteSmart($name);
$Imagen_Contenido = QuoteSmart($Imagen_Contenido);
$postdate = $year."-".$month."-".$day;
$tblname = QuoteSmart($prefix."saxon");
$tamanominimoancho=110;
function createThumb($image, $newname,$tamanominimoancho){
$size = getimagesize ($image);
$tipo= exif_imagetype($image);
$height = $size[1];
$width = $size[0];
if ($width > $height) {
$newwidth = $tamanominimoancho;
$newheight = round(($height*$tamanominimoancho)/$width);
} else {
$newheight = $tamanominimoancho;
$newwidth = round(($width*$tamanominimoancho)/$height);
}
switch($tipo){
case '2':
$src = @imagecreatefromjpeg($image) or die("problemas con la imagen $image");
break;
case '1':
$src = @imagecreatefromgif($image) or die("problemas con la imagen $image");
break;
case '3':
$src = @imagecreatefrompng($image) or die("problemas con la imagen $image");
break;
}
$im = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($im,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
//echo $newname;
imagejpeg($im, $newname,50);
imagedestroy($im);
}
$ImagenNombre=$_FILES['Imagen_Contenido']['name'];
$dir = "../imagenes/";
$dirmini = "../imagenes/miniaturas/";
$base_path = "../imagenes/".$_FILES['Imagen_Contenido']['name'];
copy($_FILES['Imagen_Contenido']['tmp_name'], $base_path);
chmod ($base_path, 0644);
$image_path = "../imagenes/" . $_FILES['Imagen_Contenido']['name'];
createThumb($dir.$ImagenNombre, $dirmini."mini_".$ImagenNombre,$tamanominimoancho);
$query = "INSERT INTO $tblname (DATE,TITLE,Imagen_Contenido,NEWS,POSTER) VALUES ('$postdate','$title','$Imagen_Contenido','$news','$name')";
if (mysql_query($query) ) {
echo "<p class=\"success\">News item - ".stripslashes($title)." (".DisplayDate(stripslashes($postdate)).") - added.</p>\n";
if($notify ==1) Notify($postdate,$title,$name,$task);
muchisimas gracias :)