Ciao ragazzi ho trovato questo script in rete, fino ad oggi ho utlizzato con qualche modifica lo script della pillala presente nel forum.
Questo lo trovo + snello, ora vorrei personalizzarlo un pochino magari aggiungendo un controllo se il file è gia presente, oppure un qualcosa per rendere il nome "unico" aggiungendo magari data e ora allafine del nome del file... sarebbe anche bello poterlo rendere multiupload, non saprei proprio da dove cominciare però
lo script è questo:
Codice PHP:
<?php
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "pictures/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "pictures/" . $imagepath; //This is the new file you saving
$file = "pictures/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 150;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
imagejpeg($tn, $save, 100) ;
$save = "pictures/sml_" . $imagepath; //This is the new file you saving
$file = "pictures/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 80;
$diff = $width / $modwidth;
$modheight = $height / $diff;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
echo "Large image: [img]pictures/".$imagepath."[/img]
";
echo "Thumbnail: [img]pictures/sml_".$imagepath."[/img]";
}
} ?>
Grazie a tutti