File Upload Error In IE
Posted: Wed Jul 08, 2009 5:46 pm
I wrote a script to re size an image that has been uploaded to a web site. It works perfectly using Firefox, in Internet Explorer it doesn't upload corectly.
Anyone know why?
Anyone know why?
Code: Select all
function resizeImage($file, $type, $newwidth, $newheight){
// test for image type chooses appropriate image function to use
if($type == "image/jpeg"){
$src = imagecreatefromjpeg($file);
} elseif($type == "image/gif") {
$src = imagecreatefromgif($file);
} elseif($type == "image/png") {
$src = imagecreatefrompng($file);
} else {
die("<h2> Unsuported image format - supported formats are .jpg, .gif, and .png</h2>");
}
list($width,$height) = getimagesize($file);
// create temp image and copy resize image to it
$tmp = imagecreatetruecolor($newwidth, $newheight);
if(imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height)){
$result = true;
} else {
$result = false;
}
// test for image type chooses appropriate image function to use
if($type == "image/jpeg"){
imagejpeg($tmp, $file, 100);
} elseif($type == "image/gif") {
imagegif($tmp, $file, 100);
} else {
imagepng($tmp, $file, 100);
}
// destroy temp images
imagedestroy($src);
imagedestroy($tmp);
return $result;
}
$image = getImage('file_upload', true, 200, 300);