Ciao a Tutti!
ho realizzato questo script di caricamento immagini. in pratica (copiando un po qua e un po la) l'obbietivo era quello di prendere un immagine da disco, faccio un po di modifiche al nome del file, e creo in automatico 2 immagini: una piccola e una grande, con dimensioni fisse prestabilite.
Il problema è che non mi da alcun errore, ma non carica anche nulla... cosa può essere? di seguito lo script...
grazie a tutti coloro che mi sapranno aiutare, o almeno ci proveranno!
Ciao!
[PHP]
$idp=$_GET['idp'];
//Imposto percorso di Memorizzazione
//$percorso="http://127.0.0.1/NonSoloLatte/prodotti/";
$percorso=$_SERVER['DOCUMENT_ROOT'].'/prodotti/';
//Recupero Nome e Tipo
$temp_img_name=$_POST['Nome'];
$tipo=$_POST['Tipo'];
//Nome Immagine Temporanea su Server
$file_temp=$_FILES['Image']['tmp_name'];
function string_replace($str){
$str=str_replace("è","e",$str);
$str=str_replace("é","e",$str);
$str=str_replace("à","a",$str);
$str=str_replace("ì","i",$str);
$str=str_replace("ò","o",$str);
$str=str_replace("ù","u",$str);
echo $str;
}
$img_name=trim($temp_img_name);
$img_name=strtolower($img_name);
do{
$img_name=str_replace(" "," ",$img_name);
}while(strpos($img_name,' ')===TRUE);
$img_name=str_replace(" ","-",$img_name);
$img_name=$img_name.'_'.$idp.'_'.$tipo;
$addr_small=$percorso.$img_name.'_small.jpg';
$addr_big=$percorso.$img_name.'_big.jpg';
//Controllo se il File è stato Caricato Correttamente
if(is_uploaded_file($_FILES['Image']['tmp_name'])){
//Salvo le Immagini
move_uploaded_file($_FILES['Image']['tmp_name'],$addr_small);
move_uploaded_file($_FILES['Image']['tmp_name'],$addr_big);
//Recupero Dimensioni
list($width, $height, $type, $attr) = getimagesize($file_temp);
//Creo la versione 120*90 dell'immagine (thumbnail)
$thumb = imagecreatetruecolor(150, 120);
$large = imagecreatetruecolor(210,250);
$source = imagecreatefromjpeg($file_temp);
imagecopyresized($thumb, $source, 0, 0, 0, 0, 150, 120, $width, $height);
imagecopyresized($large, $source, 0, 0, 0, 0, 210, 250, $width, $height);
//Ridimensiono le Immagini
imagejpeg($thumb, $percorso.$addr_small, 100);
imagejpeg($large, $percorso.$addr_big, 100);
echo 'Tes
'.getcwd();
}
}
Codice PHP:
$idp=$_GET['idp'];
//Imposto percorso di Memorizzazione
$percorso=$_SERVER['DOCUMENT_ROOT'].'/prodotti/';
//Recupero Nome e Tipo
$temp_img_name=$_POST['Nome'];
$tipo=$_POST['Tipo'];
//Nome Immagine Temporanea su Server
$file_temp=$_FILES['Image']['tmp_name'];
function string_replace($str){
$str=str_replace("è","e",$str);
$str=str_replace("é","e",$str);
$str=str_replace("à","a",$str);
$str=str_replace("ì","i",$str);
$str=str_replace("ò","o",$str);
$str=str_replace("ù","u",$str);
echo $str;
}
$img_name=trim($temp_img_name);
$img_name=strtolower($img_name);
do{
$img_name=str_replace(" "," ",$img_name);
}while(strpos($img_name,' ')===TRUE);
$img_name=str_replace(" ","-",$img_name);
$img_name=$img_name.'_'.$idp.'_'.$tipo;
$addr_small=$percorso.$img_name.'_small.jpg';
$addr_big=$percorso.$img_name.'_big.jpg';
//Controllo se il File è stato Caricato Correttamente
if(is_uploaded_file($_FILES['Image']['tmp_name'])){
//Salvo le Immagini
move_uploaded_file($_FILES['Image']['tmp_name'],$addr_small);
move_uploaded_file($_FILES['Image']['tmp_name'],$addr_big);
//Recupero Dimensioni
list($width, $height, $type, $attr) = getimagesize($file_temp);
//Creo la versione 120*90 dell'immagine (thumbnail)
$thumb = imagecreatetruecolor(150, 120);
$large = imagecreatetruecolor(210,250);
$source = imagecreatefromjpeg($file_temp);
imagecopyresized($thumb, $source, 0, 0, 0, 0, 150, 120, $width, $height);
imagecopyresized($large, $source, 0, 0, 0, 0, 210, 250, $width, $height);
//Ridimensiono le Immagini
imagejpeg($thumb, $percorso.$addr_small, 100);
imagejpeg($large, $percorso.$addr_big, 100);
echo 'Tes
'.getcwd();
}
}