vendredi 20 octobre 2017

PHP if statement doesn't work properly (paradoxical)

I've got a strange problem. I want to write a simple multiple image upload script in PHP. So there is an if statement I need for checking if the image has got the correct image type, which doesn't work as expected. The image I try to upload is a .jpg image. The "jpg" information is stored in the variable $mediaFileType, which is being checked by the if statement. Normally it should execute the script in the else statement now, but it always does the opposite and states that "jpg" != "jpg" = true. And it's obviously not. So what am I missing here?

if($mediaFileType != 'jpg' && $mediaFileType != 'png' && $mediaFileType != 'jpeg')
 {

    echo 'Wrong Media Type<br>';
    echo $mediaFileType;
    exit();

} else {
    ....
}

The website simply says:

Wrong Media Type
jpg

Aucun commentaire:

Enregistrer un commentaire