PDA

View Full Version : Upload Script: Issues with Opera and IE


tux
10-19-2008, 11:03 AM
Hi all,

I have an upload script that works fine in Opera but will not work in IE. Does anyone know of any issues with IE that would stop file uploads.

Here is part of the script, it drops out on error 4 which is the file type and size check.


if($ImgTitle && $ImgCat && $ImgURLthumb && $ImgURLmain && ($_FILES['uploadedthumb']['error'] == 0) && ($_FILES['uploadedmain']['error'] == 0)){
//FILES UPLOADS
//Check that we have a file
if((!empty($_FILES["uploadedthumb"])) && ($_FILES['uploadedthumb']['error'] == 0)) {
//Check if the file is JPEG image and it's size is less than 75k
$filename = basename($_FILES['uploadedthumb']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "jpg") && ($_FILES["uploadedthumb"]["type"] == "image/jpeg") &&
($_FILES["uploadedthumb"]["size"] < 75000)) {
//Determine the path to which we want to save this file
$target_path_thumb = "Images/Gallery/Thumbs/".$_FILES['uploadedthumb']['name'];
//Check if the file with the same name is already exists on the server
if (!file_exists($target_path_thumb)) {
//Attempt to move the uploaded file to it's new place
if ((move_uploaded_file($_FILES['uploadedthumb']['tmp_name'],$target_path_thumb))) {
$success_thumb = "Congratulations! Your 'Thumbnail' has been saved as: ".$filename;
} else {
header("location:upload.php?error=2");
exit;
}
} else {
header("location:upload.php?error=3");
exit;
}
} else {
header("location:upload.php?error=4");
exit;
}
} else {
$error_thumb = "";
}


Regards, Paul

tux
10-19-2008, 03:32 PM
Got this sorted. My problem in IE turned out to be the MIME TYPE (images/jpeg).

Apparently in their wisdom Microsoft changed their MIME TYPE in IE6 to images/pjpeg. God knows why, just to p*** us all off a bit more.

I removed the 'file type' check,

($_FILES["uploadedthumb"]["type"] == "image/jpeg")

and the upload started to work.

I would ideally like to still include it so does anyone know how I would include it to allow images/pjpeg.

Hope this helps someone else.

Regards, Paul