What's wrong with my If-statement to check uploaded file? (PHP)
Posted
by ggfan
on Stack Overflow
See other posts from Stack Overflow
or by ggfan
Published on 2010-04-05T17:08:28Z
Indexed on
2010/04/05
17:13 UTC
Read the original article
Hit count: 156
php
I am trying to test if the uploaded file is the image type I want. If it isn't a gif,jpeg, png, it should echo "Problem". But when I execute this code, it always says there's a problem. What's wrong with my if statement?
$uploadfile_type=$_FILES['userfile']['type'];
if ( ($uploadfile_type !='image/gif') || ($uploadfile_type !='image/jpeg')
|| ($uploadfile_type !='image/png'))
{
echo 'Problem: file is not a gif or jpeg or png!';
exit;
}
This code works when I am only checking one type of image. Ex: if($uploadfile_type !='image/gif') --> this statement would work but when I add a OR it doesn't.
© Stack Overflow or respective owner