lord_simeon
Registered
Използвам една готова система и като се качват снимки .jpg става няма проблеми обаче като тръгна да качвам снимки с разширение .JPG ми дава грешка ето и кода :
Кажете как да го направя като се качва .JPG да не дава грешки .Благодаря предварително
Код:
Header("Content-type: image/jpeg");
$thumbnail_picture = $_GET['picture'];
if (substr($thumbnail_picture, -4) == '.php')
die('hacking attempt...');
$thumbnail_picture = str_replace("../pictures/","",$thumbnail_picture);
if ($_GET['thumbnail'] == 'FALSE' ) {
$cache_filename = $thumbnail_picture;
$thumbnail_width = '400';
$thumbnail_height = '360';
} else {
$cache_filename = "THUMB_".$thumbnail_picture;
$thumbnail_width = '84';
$thumbnail_height = '84';
}
if (file_exists("../pictures_cache/".$cache_filename)) {
header ("Content-Length: ".filesize("../pictures_cache/".$cache_filename));
readfile ("../pictures_cache/".$cache_filename);
} else {
$system = explode('.',strtolower($thumbnail_picture));
if (preg_match('/JPG|jpeg|/',$system[1])){
$orig_image = imagecreatefromjpeg("../pictures/".$thumbnail_picture);
}
if (preg_match('/png/',$system[1])){
$orig_image = imagecreatefrompng("../pictures/".$thumbnail_picture);
}
if (preg_match('/gif/',$system[1])){
$orig_image = imagecreatefromgif("../pictures/".$thumbnail_picture);
}
list($width, $height, $type, $attr) = getimagesize("../pictures/".$thumbnail_picture);
if ($width > 450) {
$ratio = 450 / $width;
$newheight = $ratio * $height;
$newwidth = 450;
} else {
$newwidth = $width;
$newheight = $height;
}
$newwidth = $thumbnail_width;
$newheight = $thumbnail_height;
$sm_image = imagecreatetruecolor($newwidth, $newheight) or die ("Cannot Initialize GD Image");
imagecopyresampled($sm_image, $orig_image, 0, 0, 0, 0, $newwidth, $newheight,
imagesx($orig_image), imagesy($orig_image));
imagejpeg($sm_image,'',80);
imagejpeg($sm_image,"../pictures_cache/".$cache_filename,80);
imagedestroy($sm_image);
imagedestroy($orig_image);
}
?>
Кажете как да го направя като се качва .JPG да не дава грешки .Благодаря предварително