codice:if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { //percorso della cartella dove mettere i file caricati //$uploaddir = $row_RecDirImg['valore']."/"; $uploaddir = "../temp/"; //echo $uploaddir; //Recupero il percorso temporaneo del file $userfile_tmp = $_FILES['userfile']['tmp_name']; //echo "-".$userfile_tmp; //recupero il nome originale del file caricato $userfile_name = $_FILES['userfile']['name']; //echo "-".$userfile_name; $immagine1 = $userfile_name; $immagine2 = $_POST['hidimmagine2']; $immagine3 = $_POST['hidimmagine3']; $immagine4 = $_POST['hidimmagine4']; print "<pre>"; //copio il file dalla locazione temporanea alla mia cartella upload if (move_uploaded_file($userfile_tmp, $uploaddir . $userfile_name)) { //controllo che siano immagini JPG if (($HTTP_POST_FILES['userfile']['type'] != "image/pjpeg") && ($HTTP_POST_FILES['userfile']['type'] != "image/jpeg")) { print "<h1>ERROR</h1>Estensione immagine errata. "; print " E' possibile effettuare l'upload solamente per le immagini .jpg o .jpeg. "; print "Tornare indietro e riprovare</p>\n"; /*== delete uploaded file ==*/ unlink($uploaddir . $userfile_name); exit(); } //Se l'operazione è andata a buon fine... //print "File inviato con successo. Ecco alcune informazioni:\n"; //print_r($_FILES); } else { //Se l'operazione è fallta... print "Upload NON valido! Alcune informazioni:\n"; print_r($_FILES); } print "</pre>"; //-- RE-SIZING UPLOADED IMAGE /*== only resize if the image is larger than 250 x 200 ==*/ $imgfile = $uploaddir . $userfile_name; $tempfile = $uploaddir . $userfile_name; $newimage = "../immagini/".$userfile_name; $imgsize = GetImageSize($imgfile); //echo $imgsize[0]."-".$imgsize[1]; /*== check size 0=width, 1=height ==*/ if (($imgsize[0] > 250) || ($imgsize[1] > 250)) { //------start thumbnailer $thumbsize=250; //header('Content-type: image/jpeg'); list($width, $height) = getimagesize($imgfile); $width = $imgsize[0]; $height = $imgsize[1]; $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $thumbsize; $newheight = $thumbsize/$imgratio;} else{ $newheight = $thumbsize; $newwidth = $thumbsize*$imgratio;} $thumb = ImageCreateTrueColor($newwidth,$newheight); $source = imagecreatefromjpeg($imgfile); imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb,$newimage,100); //-----------end-------------- }else{ if (!copy($imgfile, $newimage)) { echo "Copia di $file non riuscita ...\n"; } } if (($imgsize[0] > 75) || ($imgsize[1] > 75)) { //------start thumbnailer //$imgfile = $newimage; $newimage = "../thumbnails/".$userfile_name; $thumbsize=75; //header('Content-type: image/jpeg'); list($width, $height) = getimagesize($imgfile); $width = $imgsize[0]; $height = $imgsize[1]; $imgratio=$width/$height; if ($imgratio>1){ $newwidth = $thumbsize; $newheight = $thumbsize/$imgratio;} else{ $newheight = $thumbsize; $newwidth = $thumbsize*$imgratio;} $thumb = ImageCreateTrueColor($newwidth,$newheight); $source = imagecreatefromjpeg($imgfile); imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb,$newimage,100); //-----------end-------------- }else{ if (!copy($imgfile, $newimage)) { echo "Copia di $file non riuscita ...\n"; } } unlink($tempfile); //print("<img src=\"$newimage\" alt=\"$immagine1\">"); } ?>