Buon dì
Ho il codice php che permette - tramite upload - di ridimensionare le immagini nei formati richiesti e pubblicarli nelle cartelle apposite
la funzione mi rinomina il file con un numero "random"
vorrei eliminare il random e mantenere lo stesso nome del file
come potete aiutarmi?
<?
$a = time();
$DirMax = '../../web/upload/'; # dir grandi
$DirMin = '../../web/upload/thumb/'; # dir thumbs
$larg = 250; # imposto la larghezza Max
$alt = 250; # imposto la altezza Max
$maxWidthB = 800; # imposto la larghezza Max
$maxHeigthB = 800; # imposto la altezza Max
//------------- Ridimensiono le Thumbs ------------------------------------------------
// $nomeImage = $a.$_FILES['blob']['name'];
$new_name = $a.".jpg";
$nomeImage = ($new_name) ? $new_name : $_FILES["upfile"]["name"];
$tmpImage = $_FILES['blob']['tmp_name'];
$src = imagecreatefromjpeg($tmpImage);
list($width,$height) = getimagesize($tmpImage);
$x_ratio = $larg / $width;
$y_ratio = $alt / $height;
if( ($width <= $larg) && ($height <= $alt) ){
$tn_width = $width;
$tn_height = $height;
}else if(($x_ratio * $height) < $alt){
$tn_height = ceil($x_ratio * $height);
$tn_width = $larg;
}else{
$tn_width = ceil($y_ratio * $width);
$tn_height = $alt;
}
$tmp=imagecreatetruecolor($tn_width,$tn_height);
imagecopyresampled($tmp,$src,0,0,0,0,$tn_width, $tn_height,$width,$height);
$filename = $DirMin.$nomeImage;
imagejpeg($tmp,$filename,80);
imagedestroy($src);
imagedestroy($tmp);
//------------- Ridimensiono le Foto Grandi -----------------------------------------
$src1 = imagecreatefromjpeg($tmpImage);
list($width,$height)=getimagesize($tmpImage);
$x_ratio = $maxWidthB / $width;
$y_ratio = $maxHeigthB / $height;
if( ($width <= $maxWidthB) && ($height <= $maxHeigthB) ){
$tn_width = $width;
$tn_height = $height;
}else if(($x_ratio * $height) < $maxHeigthB){
$tn_height = ceil($x_ratio * $height);
$tn_width = $maxWidthB;
}else{
$tn_width = ceil($y_ratio * $width);
$tn_height = $maxHeigthB;
}
$tmp = imagecreatetruecolor($tn_width,$tn_height);
imagecopyresampled($tmp,$src1,0,0,0,0,$tn_width, $tn_height,$width,$height);
$filename = $DirMax.$nomeImage;
imagejpeg($tmp,$filename,80);
imagedestroy($src1);
imagedestroy($tmp);
?>
<font face="Verdana" size="2">
File "<? echo($nomeImage); ?>"ricevuto con successo.</font>
link