Jump to content

[SOLVED] Upload simple problem


robert_gsfame

Recommended Posts

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"

 

:confused:

Link to comment
https://forums.phpfreaks.com/topic/181086-solved-upload-simple-problem/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.