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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.