Jump to content

[SOLVED] "please attach valid file type error" when attaching jpg or png


jackofalltrades

Recommended Posts

The code displays the same error if the $attachment_Size == 0, $attachment_Size >50000, and $attachment_Mime_Type is not one of the listed values. How do you know from that which condition is failing? You need unique error messages for each possible condition.

 

The  $attachment_Size == 0 will also be true for upload errors, which you need to check first before you access any of the uploaded file information - http://us2.php.net/manual/en/features.file-upload.errors.php Also, when a test fails, you need to display the value that is failing so you get feed back as to why it failed. If the $attachment_Mime_Type test fails, display $attachment_Mime_Type in the error message so that you can see what value it has in it.

 

You also don't need to unlink() the temporary uploaded file because it is automatically destroyed when the script ends.

Link to comment
Share on other sites

  • 1 month later...
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.