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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
<?php
function getFileExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
$ext = strtolower($ext);
if($ext == "jpg"|| $ext == "jpeg" || $ext == "gif" || $ext == "png")
{
}
else
{
echo"<strong>$ext</strong> type is not accepted.Please upload only JPG, Gif and PNG Extenstions";
exit();
}
return $ext;
}
function CopyImageFileGD($name,$ext,$newwidth,$newheight) {
if($ext == "jpg"){
$new_img = imagecreatefromjpeg("./gest_image_mois/images_files/$name");
}elseif($ext == "png"){
$new_img = imagecreatefrompng("gest_image_mois/images_files/$name");
}elseif($ext == "gif"){
$new_img = imagecreatefromgif("gest_image_mois/images_files/$name");
}
list($width, $height) = getimagesize("gest_image_mois/images_files/$name");
$resized_img = imagecreatetruecolor($newwidth,$newheight);
imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
ImageJpeg ($resized_img);
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
}
$ext = getFileExtension($_GET['File']);
if(!empty($_GET['File']) && !empty($_GET['w']) && !empty($_GET['h']))
{
$q1 = "update `images` set `Viewed` = Viewed+1 where `Image` = '$_GET[File]'";
mysql_query($q1) or die(mysql_error());
header('Content-Type: image/jpg');
echo $Image = CopyImageFileGD($_GET['File'],$ext,$_GET['w'],$_GET['h']);
}
?> |
Partager