PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi ppl,
I am having a strange problem here.
I have an image upload form, that works nicely from Firefox, but it doe not work in IE?
The code is below
$upload_error=$_FILES['photo']['error'];
switch($upload_error) {
case 0: //no error; possible file attack!
echo 'no error; possible file attack!';
break;
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
echo 'uploaded file exceeds the upload_max_filesize directive in php.ini';
break;
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
echo 'uploaded file exceeds the MAX_FILE_SIZE ( 10 KB ) directive that was specified in the html form';
break;
case 3: //uploaded file was only partially uploaded
echo 'uploaded file was only partially uploaded';
break;
case 4: //no file was uploaded
//$error = $error . $upload_error . ": " . $upload_error_lang[$upload_error];
echo 'no file was uploaded';
break;
default: //a default error, just in case!
$error ="<br/><br/>". $error . $upload_error . ": " . $upload_error_gen_lang;
break;
}
it always goes into the default block in IE !!
If you want I can give you the URL to test too.
saumya
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
ok, here is the link
http://www.subhvivaah.in/sam_simple_cms/admin.php
the code is below
$upload_error=$_FILES['photo']['error'];
switch($upload_error) {
case 0: //no error; possible file attack!
echo 'no error; possible file attack!';
break;
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
echo 'uploaded file exceeds the upload_max_filesize directive in php.ini';
break;
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
echo 'uploaded file exceeds the MAX_FILE_SIZE ( 10 KB ) directive that was specified in the html form';
break;
case 3: //uploaded file was only partially uploaded
echo 'uploaded file was only partially uploaded';
break;
case 4: //no file was uploaded
//$error = $error . $upload_error . ": " . $upload_error_lang[$upload_error];
echo 'no file was uploaded';
break;
default: //a default error, just in case!
$error ="<br/><br/>". $error . $upload_error . ": " . $upload_error_gen_lang;
break;
}
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
$upload_error=$_FILES['photo']['error'];
switch($upload_error) {
case 0: //no error; possible file attack!
echo 'no error; possible file attack!';
break;
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini
echo 'uploaded file exceeds the upload_max_filesize directive in php.ini';
break;
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
echo 'uploaded file exceeds the MAX_FILE_SIZE ( 10 KB ) directive that was specified in the html form';
break;
case 3: //uploaded file was only partially uploaded
echo 'uploaded file was only partially uploaded';
break;
case 4: //no file was uploaded
//$error = $error . $upload_error . ": " . $upload_error_lang[$upload_error];
echo 'no file was uploaded';
break;
default: //a default error, just in case!
$error ="<br/><br/>". $error . $upload_error . ": " . $upload_error_gen_lang;
break;
}
The error is in your javascript. The IE debugger said there error was on line 17.
if($_FILES['photo']['type'] == "image/gif"){
//First check whether upload has been success ful or not
if(is_uploaded_file($_FILES['photo']['tmp_name'])){
//Add the original filename to our target path. Result is "uploads/filename.extension"
//Renaming to my preffered name after the file has been uploaded
$target_path = $target_path . $filename.'.gif';
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target_path)) {
echo " The file ". basename( $_FILES['photo']['name'])." has been <b>successfully uploaded</b>";
} else{
echo "There was an error uploading the file, please try again!";
}
}else{
echo $_FILES['photo']['error'];
}