This topic is locked

How to restrict image upload types

11/18/2008 11:18:51 AM
PHPRunner General questions
L
Lisa2006 author

Hi Forum,
I have a field called "vehicle_pic", set to longtext in my DB Table.
I've set my project to upload images. I'm able to upload .jpg and .gif files successfully.
Here's the problem

If I try to upload a file with extention .txt or .exe (anything other than .jpg or .gif) it produces an error page as follows:
PHP error happened
Error type 2

Error description: imagecreatefromstring() [function.imagecreatefromstring]: Empty string or invalid image

etc.
I would like to be able to display an error message such as "Sorry you have chosen the wrong file type" should the user tries to upload anything other than a .jpg or .gif file.

I need this to occur when the user is adding a record. I do not want the user to get the above error page as this gives the impressions that the application has failed.
Thank you in advance.
Lisa

J
Jane 11/19/2008

answered in your personal email.