mime types with php uploader works in mozilla etc and not IE
Posted: Tue Jan 13, 2004 4:11 pm
Surprise surprise! 
Well, here is what happens:
In Mozilla and Safari and Firebird etc etc my image upload form works just fine.
In IE I get this error:
Looking at my code snippet, here is the part that has the mime type stuff:
I'm wondering if there is some bug in IE that is causing it to bail where mozilla/firebird/safari etc are all fine with it?
Is it a php thing (passing variables) that IE can't handle?
Has anyone come across such a thing?
VERY strange.
I really appreciate anyone looking at this. Again, it's one of those things I've spent a couple of days on now and am just finding it hard to see any angles that could be wrong now. Some fresh eyes perhaps?
Thanks a ton!
Rob
Well, here is what happens:
In Mozilla and Safari and Firebird etc etc my image upload form works just fine.
In IE I get this error:
Code: Select all
Only image/jpeg files may be uploaded.Code: Select all
#--------------------------------#
# Variables
#--------------------------------#
// The path to the directory where you want the
// uploaded files to be saved. This MUST end with a
// trailing slash unless you use $path = ""; to
// upload to the current directory. Whatever directory
// you choose, please chmod 777 that directory.
$path = "d:/path/to/site/html/files/";
// The name of the file field in your form.
$upload_file_name = "userfile";
// ACCEPT mode - if you only want to accept
// a certain type of file.
// possible file types that PHP recognizes includes:
//
// OPTIONS INCLUDE:
// text/plain
// image/gif
// image/jpeg
// image/png
// Accept ONLY gifs's
#$acceptable_file_types = "image/gifs";
// Accept JPEG files
$acceptable_file_types = "image/jpeg";
// Accept ALL files
#$acceptable_file_types = "";
// If no extension is supplied, and the browser or PHP
// can not figure out what type of file it is, you can
// add a default extension - like ".jpg" or ".txt"
$default_extension = ".jpg";
// MODE: if your are attempting to upload
// a file with the same name as another file in the
// $path directory
//
// OPTIONS:
// 1 = overwrite mode
// 2 = create new with incremental extention
// 3 = do nothing if exists, highest protection
$mode = 1;
#--------------------------------#
# PHP
#--------------------------------#
if (isset($_REQUEST['submitted'])) {
/*
A simpler way of handling the submitted upload form
might look like this:
$my_uploader = new uploader('en'); // errors in English
$my_uploader->max_filesize(30000);
$my_uploader->max_image_size(800, 800);
$my_uploader->upload('userfile', 'image/gif', '.gif');
$my_uploader->save_file('uploads/', 2);
if ($my_uploader->error) {
print($my_uploader->error . "<br><br>\n");
} else {
print("Thanks for uploading " . $my_uploader->file['name'] . "<br><br>\n");
}
*/
// Create a new instance of the class
$my_uploader = new uploader($_POST['language']); // for error messages in french, try: uploader('fr');
// OPTIONAL: set the max filesize of uploadable files in bytes
$my_uploader->max_filesize(1500000);
// OPTIONAL: if you're uploading images, you can set the max pixel dimensions
$my_uploader->max_image_size(2000, 2000); // max_image_size($width, $height)
// UPLOAD the file
if ($my_uploader->upload($upload_file_name, $acceptable_file_types, $default_extension)) {
$my_uploader->save_file($path, $mode);
}
if ($my_uploader->error) {
echo $my_uploader->error . "<br><br>\n";
} else {
// Successful upload!
print("<b>DEBUG INFO:</b> ". $my_uploader->file['name'] . " was successfully uploaded! <a href="" . $_SERVER['PHP_SELF'] . "">Click here to upload another</a><br>");
$oldfilename = "$my_uploader->file['name']";
// Print all the array details...
//print_r($my_uploader->file);
}I'm wondering if there is some bug in IE that is causing it to bail where mozilla/firebird/safari etc are all fine with it?
Is it a php thing (passing variables) that IE can't handle?
Has anyone come across such a thing?
VERY strange.
I really appreciate anyone looking at this. Again, it's one of those things I've spent a couple of days on now and am just finding it hard to see any angles that could be wrong now. Some fresh eyes perhaps?
Thanks a ton!
Rob