Image Upload Script Works in Chrome but not IE ?
Posted: Thu Aug 12, 2010 11:41 am
Hi there I have made an image upload script for social network site I am building for users to upload there pictures.
It works as it should in Google Chrome browser but is not working in IE what am I missing I am using IE 8 as well.
When this is run in IE it produces the "name' is not an accepted image file" message every time no mater what format or
size image I upload however when I run same script in Chrome it works as it should ??
Anyone know why its not working as it should in IE ?
PHP Code:
<?php
echo <<<_END
<html><head><title>PHP Form Upload Secure</title></head><body>
<form method='post' action='dansuploadv.php' enctype='multipart/form-data'>
Select a JPG, GIF, PNG or TIF File:
<input type='file' name='filename' size='10' />
<input type='submit' value='Upload' /></form>
_END;
IF ($_FILES)
{
$name = $_FILES['filename']['name'];
switch($_FILES['filename']['type'])
{
case 'image/jpeg': $ext = 'jpg'; break;
case 'image/gif': $ext = 'gif'; break;
case 'image/png': $ext = 'png'; break;
case 'image/tiff': $ext = 'tif'; break;
default: $ext = ''; break;
}
if ($ext)
{
$n = "user_profile_image.$ext";
move_uploaded_file($_FILES['filename']['tmp_name'], $n);
echo "Uploaded image '$name' as '$n':<br>";
echo "<img src='$n' />";
}
else echo "'$name' is not an accepted image file";
}
else echo "No image has been uploaded";
echo "</body></html>";
?>
It works as it should in Google Chrome browser but is not working in IE what am I missing I am using IE 8 as well.
When this is run in IE it produces the "name' is not an accepted image file" message every time no mater what format or
size image I upload however when I run same script in Chrome it works as it should ??
Anyone know why its not working as it should in IE ?
PHP Code:
<?php
echo <<<_END
<html><head><title>PHP Form Upload Secure</title></head><body>
<form method='post' action='dansuploadv.php' enctype='multipart/form-data'>
Select a JPG, GIF, PNG or TIF File:
<input type='file' name='filename' size='10' />
<input type='submit' value='Upload' /></form>
_END;
IF ($_FILES)
{
$name = $_FILES['filename']['name'];
switch($_FILES['filename']['type'])
{
case 'image/jpeg': $ext = 'jpg'; break;
case 'image/gif': $ext = 'gif'; break;
case 'image/png': $ext = 'png'; break;
case 'image/tiff': $ext = 'tif'; break;
default: $ext = ''; break;
}
if ($ext)
{
$n = "user_profile_image.$ext";
move_uploaded_file($_FILES['filename']['tmp_name'], $n);
echo "Uploaded image '$name' as '$n':<br>";
echo "<img src='$n' />";
}
else echo "'$name' is not an accepted image file";
}
else echo "No image has been uploaded";
echo "</body></html>";
?>