robert_gsfame Posted November 11, 2009 Share Posted November 11, 2009 Really confused!! I run once and it worked, but when i tried today...it didn't work Which part is missing if(isset($_POST['upload'])){ $filename=$_FILES['file']['name']; $filetype=$_FILES['file']['type']; $filesize=$_FILES['file']['size']; if(empty($filename)){ $warning="<span class=style2><font color=red>* You did not upload any file</font></span>";}else if((!empty($filename))&&($filetype!='application/msword')){ $warning="<span class=style2><font color=red>* Word document only allowed to be uploaded</font></span>"; }else if((!empty($filename))&&($filesize>120000)){ $warning="<span class=style2><font color=red>* File size exceeds maximum allowed</font></span>"; }else{ COPY TO UPLOAD BLABLABLA..} THe problem is that when i upload the word document with less than 120 kb filesize, "* Word document only allowed to be uploaded" Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted November 11, 2009 Author Share Posted November 11, 2009 I just tried in IE 6.0 and it works How to make both mozilla and IE works?? Is it because MIME ?? Please help me solving this..thx Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 11, 2009 Share Posted November 11, 2009 When you are validating user supplied information and you expect it to have a specific value in a test, it is usually a good idea to display the actual value that fails a test so that you know exactly what was received. Also, your posted code is NOT checking for any of the possible upload errors before attempting to test the ["type"] or ["size"] elements. It is likely that the upload actually failed and the ["type"] is empty - http://us.php.net/manual/en/features.file-upload.errors.php Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted November 11, 2009 Author Share Posted November 11, 2009 Like i told you when i run my script on IE 6.0, file uploaded..but when i run it on mozilla, file didn't upload Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted November 11, 2009 Share Posted November 11, 2009 Different browsers provide different ["type"] for the same file. Until you display the value that is failing the test of the ["type"] element, no one can help you solve the problem. Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted November 11, 2009 Author Share Posted November 11, 2009 so what should i do to have it works for both mozilla and IE Please tell me in detail.. i really need your helps Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted November 11, 2009 Author Share Posted November 11, 2009 okay, i got the solution!!! ;D it should be application/msword && application/doc TOPIC CLOSED!!! Quote Link to comment 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.