saumya Posted February 26, 2007 Share Posted February 26, 2007 hi guys, I have a form, which submits data to a DB and uploads a photo to the server.While the script works just nice in Firefox and Opera, it is not working in IE ? With IE, the data gets into the DB but the photo does not upload. Here is the link to the view page http://www.subhvivaah.in/sam_simple_cms/index.php The form is at below link http://www.subhvivaah.in/sam_simple_cms/admin.php Thanking you saumya Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/ Share on other sites More sharing options...
suzzane2020 Posted February 26, 2007 Share Posted February 26, 2007 do u get any error in IE Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194142 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 It works for me in both IE7 and FireFox. But i think your problem is that your doing checks on the fields after you upload the file and insert to the database Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194155 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 Oops, sorry i was uploading Gif images.. Can you send us a bit of relevant code in order to help us assess the problem Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194161 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 Thank you people, for your answers.But is it really works in IE?!! Actaully the data gets into the DB but the problem is the image.It does not upload in IE !! Here is the code I am using to upload the image $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! Smile $error ="<br/><br/>". $error . $upload_error . ": " . $upload_error_gen_lang; break; } Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194177 Share on other sites More sharing options...
TRI0N Posted February 26, 2007 Share Posted February 26, 2007 Thats the results filter but not the file handler. Is ther more that is used to determine where it may be having a fault.. I'm supprised for one that it works in Firefox and not IE.. Firefox is pretty strict about what it shows people compared to IE. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194189 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 hi TRI0N, thats the thing surprised me too. Even it works in Opera. But not in IE. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194197 Share on other sites More sharing options...
TRI0N Posted February 26, 2007 Share Posted February 26, 2007 Well for on Opera will show you almost anything aslong as you don't make it "Burp". But Fireforx will its pretty well sctipted down.. So show us some of the raw code that build the results if it is accepeted. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194205 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 I think you may have gathered this already but both browsers have no trouble actually showing the pictures. As TR1ON says what we need to see is the actual code where you are uploading the picture.. Also where are you uploading the picture to? A directory or a Database Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194209 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 ok, here are my scripts. The main page is <?Php //includes..................the necessary Scripts.............................. include_once('php_includes/connectdb.php'); include_once('php_includes/img_upload.php'); //............END..............include....................................................... echo<<<HERE <html> <head> <title>Thane Guide : simple CMS</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <LINK REL="stylesheet" HREF="final.css" TYPE="text/css"> HERE; ?> <script language="javascript" type="text/javascript" src="javascript/downLoaded/datetimepicker.js"></script> <script language="JavaScript" type="text/JavaScript"> <!-- //Addign page specific functions function checkAndSubmit() { var pName=document.add_item.item_name.value; if(pName=='') { alert ( 'Please fill the form' ); }else{ //alert ( 'Submitting : '+pName ); document.add_item.submit(); } } //--> </script> </head> <body> <form action="admin.php" name="add_item" method="POST" enctype="multipart/form-data" > Product Name : <input type="text" name="item_name"/><br/> <input type="Hidden" name="MAX_FILE_SIZE" value="10000"/> Image : <input type="file" name="photo" /><br/> Details : <textarea cols="50" rows="10" name="item_detail"></textarea></br> Entry date : <!-- Adding Date chooser Calender --> <input name="date_of_entry" type="text" size="15" id="entry_date" readonly/> <a href="javascript:NewCal('entry_date','YYYYMMDD')"><img src="img/cal.gif" width="16" height="16" border="0" alt="Pick a date"></a><br/> <input type="Reset"/> <input type="Button" value="Add Product" onClick="checkAndSubmit();"/> </form> <?Php //checks for form submission if(isset($_POST['item_name'])){ connectDbServer(); selectDB('universal'); //gets from the form submiited $item_name = $_POST['item_name']; $item_detail = $_POST['item_detail']; $date_of_entry = $_POST['date_of_entry']; $query = "INSERT INTO `basic_cms` (`product_no`, `product_detail`, `date_of_entry`) VALUES ('$item_name', '$item_detail', '$date_of_entry');"; putMyData($query); //echo "$first_name_student $last_name_student is going to be added"; //after putting the data, we will get it to name our file name according to the id of the student in DB $query = "SELECT * FROM `basic_cms`;"; //Getting the detail values if( !$result = mysql_query($query) ){ die('Could not execute the query to get students\' data : ' . mysql_error()); }else{ // get the last auto incremented value $lastItemID = mysql_insert_id(); } //name the file according to the ID of the student $filename=$lastItemID; //upload the photo uploadTheFile($filename); }else{ echo 'Please fill the form to add new Product '; } ?> </body></html> Now the upload image page is <?Php //......................................UPLOAD...function.................................................................. function uploadTheFile($filename){ // Where the file is going to be placed $target_path = "uploaded_form_images/"; $uploadingfileIs= basename( $_FILES['photo']['type']); if($uploadingfileIs=='jpeg'){ //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" //$target_path = $target_path . basename( $_FILES['photo']['name']); //Renaming to my preffered name after the file has been uploaded //$target_path = $target_path . 'myFile.jpg'; $target_path = $target_path . $filename.'.jpg'; 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']; } }else{ echo 'Please select <b>only jpeg files</b> to upload. '; $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 = $error . $upload_error . ": " . $upload_error_gen_lang; break; } } } //.................................................END UPLOAD.....function............................................. ?> Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194212 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 I could be wrong but it seems your checking the image type all wrong Should be checking for a MIME type if($uploadingfileIs=='jpeg') try this if($uploadingfileIs=='image/jpeg') Let me know whether or not this works? Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194215 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 hi magnetica, Thank you for the help. But, that is not working.I have uploaded with your code. You can check for your self in the links. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194229 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 Is the code still the same because I dont think it's working in FF now either.. If so change it back, although using MIME types is the proper way to do it Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194236 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 hi magnetica, The code is the same. You are right, now it stopped working in FireFox too . I will be changing it soon and updating to the previous version. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194242 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 Its a far-cry but try replacing: $uploadingfileIs= basename( $_FILES['photo']['type']); if($uploadingfileIs=='jpeg') With: if ($_FILES['photo']['type']== "image/jpeg" ) OR if ($_FILES['photo']['type'] == "jpeg" ) This is how it works on my site Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194253 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 hi magnetica, Thank you.I appreciate your patience. But still its not working in IE. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194262 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 Can I ask why exactly it is you only want jpeg pictures because I just been playing round with mine and it would seem it doesn't like jpeg but I know for a fact the below works with both FF and IE if ($_FILES["photo"]["type"] == "image/gif" ) Just depends on how much you want your pictures to be jpeg Let us know Also as you know: if ($_FILES["photo"]["type"] == "jpeg" ) works in FF but not IE and if ($_FILES["photo"]["type"] == "image/pjpeg" ) works in IE but not FF Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194266 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 I do not mind changing it to "gif" ? But, there is no way, jpeg image will work in both FF and IE ?!! i will try for gif now, if "jpeg" is the thing which is making all the problems. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194271 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 Well I tried it with "image/gif" and it worked fine in both... See how it goes Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194275 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 ohh maan, thank you sooooooo much !! That worked great for me too . Look at http://www.subhvivaah.in/sam_simple_cms/index.php last 2 images are gif and both worked in both the browsers. I can go ahead with my project in GIF.Thank you so much. But the question is still there for JPEG. I would really like o dive into the complexions happening in JPEG . Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194278 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 But Gif files are much smaller in filesize than Jpeg The only other way to upload Jpeg with both is: if ($_FILES["photo"]["type"] == "image/pjpeg" ){ //UPLOAD CODE FOR IE } elseif ($_FILES["photo"]["type"] == "jpeg" ){ //UPLOAD CODE FOR FF } Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194279 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 hi magnetica , thank you so much. I appreciate your help and concern. I am completely agreed that gifs are smaller and stuff. But I was wondering how PHP is handling the files. Well, for the solution to JPEGs, I also thought the same, to put a check for both. Lets see if we can make it any other way. Cheers magnetica and thank you for your help. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194290 Share on other sites More sharing options...
magnetica Posted February 26, 2007 Share Posted February 26, 2007 I did try this way of checking both but it threw an error at me saying too unexpected T_ELSE or something Anyway I think this is because my upload script is quite complicated and probably put it in the wrong place.. Have you tried this? Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194294 Share on other sites More sharing options...
redarrow Posted February 26, 2007 Share Posted February 26, 2007 There nothink wrong with your code all you got to do is increse the max_file_size in the form ok. set it to somethink like 30000000000000 then do a strlen check for size of file ok. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194295 Share on other sites More sharing options...
saumya Posted February 26, 2007 Author Share Posted February 26, 2007 I have not tried yet buddy, but I agree with redarrow in this regard. The error is because of the Max file size. But i will try it in sometime. Quote Link to comment https://forums.phpfreaks.com/topic/40123-works-on-firefox-opera-but-not-in-ie/#findComment-194298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.