Codice PHP:
//Imposto percorso di Memorizzazione
$percorso="/demo/office/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';
list($width, $height, $type, $attr) = getimagesize($_FILES['Image']['tmp_name']);
echo "<pre>";
print_r(getimagesize($_FILES['Image']['tmp_name']));
if(is_uploaded_file($_FILES['Image']['tmp_name']))
{
move_uploaded_file($_FILES['Image']['tmp_name'],$addr_small);
move_uploaded_file($_FILES['Image']['tmp_name'],$addr_big);
$thumb_small = imagecreatetruecolor(150, 120);
$thumb_big = imagecreatetruecolor(220, 250);
$source_small = imagecreatefromstring(file_get_contents($addr_small));
$source_big = imagecreatefromstring(file_get_contents($addr_big));
imagecopyresized($thumb_small, $source_small, 0, 0, 0, 0, 150, 120, $width, $height);
imagecopyresized($thumb_big, $source_big, 0, 0, 0, 0, 210, 250, $width, $height);
header('content-type: image/jpeg');
imagejpeg($addr_small);
imagejpeg($addr_big);
}
giustamente non funziona ancora, ma credo sia sulla buona strada... mi ha inserito una nuova cosa imagecreatefromstring(); che non ho la più pallida idea di cosa sia...