Archivo resize.php
Código PHP:
<?php
class thumbnail
{
var $img;
function thumbnail($imgfile)
{
//detectando el formato de la imagen
$this->img["format"]=ereg_replace(".*\.(.*)$","\\1",$imgfile);
$this->img["format"]=strtoupper($this->img["format"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
$this->img["format"]="JPEG";
$this->img["src"] = ImageCreateFromJPEG ($imgfile);
} elseif ($this->img["format"]=="PNG") {
//PNG
$this->img["format"]="PNG";
$this->img["src"] = ImageCreateFromPNG ($imgfile);
} elseif ($this->img["format"]=="GIF") {
//GIF
$this->img["format"]="GIF";
$this->img["src"] = ImageCreateFromGIF ($imgfile);
} elseif ($this->img["format"]=="WBMP") {
//WBMP
$this->img["format"]="WBMP";
$this->img["src"] = ImageCreateFromWBMP ($imgfile);
} else {
//defecto
echo "Not Supported File";
exit();
}
@$this->img["lebar"] = imagesx($this->img["src"]);
@$this->img["tinggi"] = imagesy($this->img["src"]);
//calidad por defecto jpeg
$this->img["quality"]=75;
}
function size_height($size=100)
{
//alto
$this->img["tinggi_thumb"]=$size;
@$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
}
function size_width($size=100)
{
//ancho
$this->img["lebar_thumb"]=$size;
@$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
}
function size_auto($size=100)
{
//tamaño
if ($this->img["lebar"]>=$this->img["tinggi"]) {
$this->img["lebar_thumb"]=$size;
@$this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"];
} else {
$this->img["tinggi_thumb"]=$size;
@$this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"];
}
}
function jpeg_quality($quality=75)
{
//jpeg calidad
$this->img["quality"]=$quality;
}
function show()
{
//el thumb
@Header("Content-Type: image/".$this->img["format"]);
$this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
@imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
imageJPEG($this->img["des"],"",$this->img["quality"]);
} elseif ($this->img["format"]=="PNG") {
//PNG
imagePNG($this->img["des"]);
} elseif ($this->img["format"]=="GIF") {
//GIF
imageGIF($this->img["des"]);
} elseif ($this->img["format"]=="WBMP") {
//WBMP
imageWBMP($this->img["des"]);
}
}
function save($save="")
{
//guarda el thumb
if (empty($save)) $save=strtolower("./thumb.".$this->img["format"]);
$this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]);
@imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]);
if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG") {
//JPEG
imageJPEG($this->img["des"],"$save",$this->img["quality"]);
} elseif ($this->img["format"]=="PNG") {
//PNG
imagePNG($this->img["des"],"$save");
} elseif ($this->img["format"]=="GIF") {
//GIF
imageGIF($this->img["des"],"$save");
} elseif ($this->img["format"]=="WBMP") {
//WBMP
imageWBMP($this->img["des"],"$save");
}
}
}
?>
xx.php
Código PHP:
$repo_dir = "propiedades/casa";
if( ! is_dir($repo_dir)){
mkdir( $repo_dir );
}
$user_dir = $repo_dir."/".$aData['calle'];
if( ! is_dir($user_dir)){
mkdir( $user_dir );
}
$misImagenes = array( $_FILES['foto1'], $_FILES['foto2'], $_FILES['foto3'], $_FILES['foto4'], $_FILES['foto5'], $_FILES['foto6'], $_FILES['foto7'], $_FILES['foto8'], $_FILES['foto9'], $_FILES['foto10'] );
foreach( $misImagenes as $img ){
if( $img ){
move_uploaded_file( $img['tmp_name'], $user_dir.'/'.$img['name'] );
require_once( "resize.php" );
$thumb = new thumbnail( $user_dir.'/'.$img['name'] );
$thumb->size_auto(320);
$thumb->save($user_dir.'/thumb_'.$img['name']);
Luego hago un query para guardar los path en la base de datos.-
El error que emite es el echo
echo "Not Supported File";
Mil gracias a todos!