If you are talking about $_FILES['userfile']['type']
, this information is sent by the browser. It may or may not be present, and even if its present, you should relate to it just like any other user input.
If you are interested in checking images, you can use the getimagesize function to determine the type of file. This function returns NULL for images that it cannot understand. Even if it returns a valid image type, you can still reject the file, for example. if you expect GIF and JPEG, and instead you get TIFF.
In addition, the web server will determine whether to execute a file that does not depend on file permissions (the execution bit and the shebang line) and the file extension. If you keep a check on these two, you're probably fine.
Salman a
source share