If/else isn't working properly
Posted
by luckytaxi
on Stack Overflow
See other posts from Stack Overflow
or by luckytaxi
Published on 2010-03-18T18:13:05Z
Indexed on
2010/03/18
18:21 UTC
Read the original article
Hit count: 385
php
|codeigniter
I have a validation function I'm using inside of codeigniter.
function valid_image() {
if ( ($_FILES["file"]["type"] != "image/jpeg") || ($_FILES["file"]["type"] != "image/gif") ) {
$this->form_validation->set_message('valid_image', 'Wrong file type..');
return false;
} else {
return true;
}
With just the "image/jpeg" part in the if statement it works fine. If I try to upload anything other than a jpg file it fails. If I run the code above, it fails with both a jpg or a gif file.
And before someone says "why not use the upload class," I can't. I'm saving my pics directly into MongoDB, so the upload class doesn't help much.
© Stack Overflow or respective owner