Jump to content

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


jackofalltrades

Recommended Posts

I am stumped as to why I am getting this error only with these filetypes. I have attached my php code. Any help greatly appreciated.

 

Thank you for any help you can give. I really appreciate it.

 

[attachment deleted by admin]

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.

  • 1 month later...

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.