I'm trying to allow members to upload a picture to the my website. I In my php code I test the uploaded files for type. For some files it works fine, but I've discovered there are .jpg files that don't seem to have the internal type headers and the php $_FILES array will not have any data in the type variable.

if (($_FILES["$Flnm"]["type"] == "image/gif")
  || ($_FILES["$Flnm"]["type"] == "image/jpg")
  || ($_FILES["$Flnm"]["type"] == "image/png")
  || ($_FILES["$Flnm"]["type"] == "image/jpeg")
  || ($_FILES["$Flnm"]["type"] == "image/pjpeg"))

This is the 'if' test for type, but on some files this variable is blank.
The thing is the files that return a type blank are first download from my Kodak digital camera. However I know that these files are accepted on other web site like Craig's List. So I think there must be a work around.

5 Years
Discussion Span
Last Post by ddymacek

So you need to process them a different way. Or decide if you want to accept the file or not. The whole point of checking the file type is to make sure you are getting a specific type of file. So if the image type comes across as blank, save it in a 'safe' folder and perhaps send an email to somebody to verify the image is an image before moving the file into the users account or whatever you are doing.
Or even easier, tell the end user that the file they are trying to upload does not have an image type associated with it. use a photo editor to convert/save the image as a jpg and re-upload. gimp is a free editor. There may be some online tools to convert photos as well.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.