PDA

View Full Version : Checking file type...


Jabbamonkey
08-20-2002, 12:48 AM
I'm having a user upload a file. If the file isn't an image file, I want to send them an error message. I tried the following...


if ($file_type != "image/gif" || $file_type != "image/pjpeg" || $file_type != "image/jpeg")
{ $error = "File Error - Not an image file (".$file_type.")"; }

if ($error) { echo $error; }



Unfortunately, I keep getting my error message ...

File Error - Not an image file (image/pjpeg)

... but that IS what the file type is ... I'm confused. Anyone know why this is happening? Did I miss something ... I've been staring at this code for so long...

Spookster
08-20-2002, 01:17 AM
It seems to me that you have already opened a few topics asking this same question or similar questions. You will need to keep it under one topic if you don't wish me to close the topic.

Here is one instance where you have already asked this question:

http://www.codingforums.com/showthread.php?s=&threadid=4069

Jabbamonkey
08-20-2002, 01:32 AM
The first topic asked HOW to check file type. I learned that $file_type is the actual type. Question answered.

This new post is not asking HOW to get a file type. This new post simply asks why the if-statement isn't working ... which it should be.

The statement could have been re-written without mentioning file type - but I've got other things to do.

Jabbamonkey