1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| $_FILES['image']['name'] = str_replace(" ","_","","","^","","","",$_FILES['image']['name']);
if (filesize($_FILES['image']['tmp_name']) > 100000)
{
echo "<script language=javascript> alert ('Photo 1 trop gros dois faire -100ko!');</script>";
echo "<script language=\"javascript\">location=\"add_annonce.php\";</script>";
exit;
}
else
{
$ext = strtolower(substr($_FILES['image']['name'],strrpos($_FILES['image']['name'], ".")+1));
$valides = array("jpg","jpeg","JPG","GIF","gif","PNG","png");
if(in_array($ext,$valides))
{
move_uploaded_file($image, "images/".$_FILES['image']['name']."");
$name_image ="images/".$_FILES['image']['name']."";
switch( $source )
{
case "gif" : imagecreatefromgif($name_image); break;
case "jpg" : imagecreatefromjpeg($name_image); break;
case "png" : imagecreatefrompng($name_image); break;
}
$largeur = 150; $hauteur= 125;
$largeur_source = imagesx($source);
$hauteur_source = imagesy($source);
if($hauteur_source>$largeur_source)
{
$l = $hauteur; $h = $largeur;
$lSrc = $hauteur_source; $hSrc = $largeur_source;
}else{
$l = $largeur; $h = $hauteur;
$lSrc = $largeur_source; $hSrc = $hauteur_source;
}
$destination = imagecreatetruecolor($l, $h);
$largeur_destination = imagesx($destination);
$hauteur_destination = imagesy($destination);
imagecopyresampled($destination, $source, 0, 0, 0, 0, $largeur_destination, $hauteur_destination, $largeur_source, $hauteur_source);
$textcolor = imagecolorallocate($destination, 255, 255, 255);
imagestring($destination, 4, 5, $h-25, "Hesbaye-Immo", $textcolor);
$image_mini = strtr(''.$_FILES['image']['name'].'', " ","%20");
imagegif ($destination,'images/mini/'.$_FILES['image']['name'].'');
imagejpeg ($destination,'images/mini/'.$_FILES['image']['name'].'');
imagepng ($destination,'images/mini/'.$_FILES['image']['name'].'');
}
else
{
echo "<script language=javascript> alert ('Uniquement format, jpg, jpeg, JPG,GIF,gif,PNG,png!');</script>";
}
} |
Partager