balkan7 Posted February 24, 2009 Share Posted February 24, 2009 Hi guys, i really confused why this code doesn't work on IE, i have tested on FF working fine. code is: <?php if (isset($_FILES['slika']['name']) and $_FILES['slika']['name'] != ""){ if (is_uploaded_file($_FILES['slika']['tmp_name'])) { $types = array(".jpeg", ".JPEG", ".jpg", ".JPG", ".gif", ".GIF", ".png", ".PNG"); $ext = strtolower(strrchr($_FILES['slika']['name'], ".")); $slika = strtolower($_FILES['slika']['name']); if (file_exists("../sliki/galerija/".$slika)){ $novo_ime = time(); $slika = $novo_ime . strtolower($_FILES['slika']['name']); } $slika_temp = $_FILES['slika']['tmp_name']; $mesto = "../sliki/galerija/".$slika; if (in_array($ext, $types)) { move_uploaded_file($slika_temp, $mesto); } $pat = $slika; $slika_org = "../sliki/galerija/". $slika; $snimi = "../sliki/galerija/slikicki/". $slika; list($width, $height) = getimagesize($slika_org); $sirina = 140; //$diff = $width / $sirina; $visina = 115; if ($_FILES['slika']['type'] == "image/jpg" or $_FILES['slika']['type'] == "image/jpeg"){ $tn = imagecreatetruecolor($sirina, $visina) ; $image = imagecreatefromjpeg($slika_org) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $sirina, $visina, $width, $height) ; imagejpeg($tn, $snimi, 100) ; } else if($_FILES['slika']['type'] == ".gif" or $_FILES['slika']['type'] == ".gif"){ $tn = imagecreatetruecolor($sirina, $visina) ; $image = imagecreatefromgif($slika_org) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $sirina, $visina, $width, $height) ; imagegif($tn, $snimi, 100) ; } $slikicka = "slikicki/". $pat; } } else { $slika = ""; $slikicka = ""; } ?> Link to comment https://forums.phpfreaks.com/topic/146684-solved-create-thumbnails-working-on-ff-doesnt-work-on-ie/ Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 What "doesn't work" about it? Link to comment https://forums.phpfreaks.com/topic/146684-solved-create-thumbnails-working-on-ff-doesnt-work-on-ie/#findComment-770107 Share on other sites More sharing options...
balkan7 Posted February 24, 2009 Author Share Posted February 24, 2009 hi rhodesa, this is code for create thumbnails, but i have tested on FF working great, in IE cannot create only jpg thumbnail. on gif i have changed code to: <?php else if($_FILES['slika']['type'] == "image/gif"){ ?> and now working on IE, only jpg, jpeg cannot create thumbnails. Link to comment https://forums.phpfreaks.com/topic/146684-solved-create-thumbnails-working-on-ff-doesnt-work-on-ie/#findComment-770111 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 Yeah, IE likes to upload JPEGs as "Progressive JPEGs" which have a content type of "image/pjpeg"...stupid, i know. to see the issue for yourself, and to debug this in the future, add an ELSE clause so it looks like: if ($_FILES['slika']['type'] == "image/jpg" or $_FILES['slika']['type'] == "image/jpeg"){ $tn = imagecreatetruecolor($sirina, $visina) ; $image = imagecreatefromjpeg($slika_org) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $sirina, $visina, $width, $height) ; imagejpeg($tn, $snimi, 100) ; } else if($_FILES['slika']['type'] == ".gif" or $_FILES['slika']['type'] == ".gif"){ $tn = imagecreatetruecolor($sirina, $visina) ; $image = imagecreatefromgif($slika_org) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $sirina, $visina, $width, $height) ; imagegif($tn, $snimi, 100) ; }else{ die($_FILES['slika']['type'] . " is not a valid Content-Type"); } then, adjust your first if statement to have the new content type Link to comment https://forums.phpfreaks.com/topic/146684-solved-create-thumbnails-working-on-ff-doesnt-work-on-ie/#findComment-770116 Share on other sites More sharing options...
balkan7 Posted February 24, 2009 Author Share Posted February 24, 2009 i get this result on jpg, jpeg: (image/pjpeg is not a valid Content-Type) solution for this one ? Link to comment https://forums.phpfreaks.com/topic/146684-solved-create-thumbnails-working-on-ff-doesnt-work-on-ie/#findComment-770120 Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 Did you write this code? if ($_FILES['slika']['type'] == "image/jpg" or $_FILES['slika']['type'] == "image/jpeg" or $_FILES['slika']['type'] == "image/pjpeg"){ Well either way, this is how you fix it. Link to comment https://forums.phpfreaks.com/topic/146684-solved-create-thumbnails-working-on-ff-doesnt-work-on-ie/#findComment-770122 Share on other sites More sharing options...
balkan7 Posted February 24, 2009 Author Share Posted February 24, 2009 Working perfectly. thanks for support! Link to comment https://forums.phpfreaks.com/topic/146684-solved-create-thumbnails-working-on-ff-doesnt-work-on-ie/#findComment-770128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.