Jump to content

[SOLVED] Uploaded file type checking


Quendian

Recommended Posts

I am using a form to upload a file but I'm having trouble checking the file type.

I only want the user to be able to upload .jpg and .jpeg file formats so I check the file type like so:

 

if(($_FILES["file"]["type"] != "image/jpeg") || ($_FILES["file"]["type"] != "image/jpg"))
{
   echo "Image not in correct format (". $_FILES["file"]["type"] . ").";
}

 

But even when I upload an image with the correct file type it complains?

 

How embarrassing, I fixed it. I was using the wrong operator in the if statement. I replaced it with && and it worked. Sorry.

Link to comment
https://forums.phpfreaks.com/topic/161823-solved-uploaded-file-type-checking/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.