That page doesn't provide the actual INT value of each one but you should be able to print a few to get the values as necessary. An entire list of them can be found on that page, towards the bottom. A check is also added when moving the file so that if the target directory doesn’t have write permissions or you run out of disk space or what-have-you, it throws a meaningful error… I put the directory to move the file into in as a variable at the top for easy modification… and I cleaned up the markup into something a wee bit more valid and modern. This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. That index contains the value of one of PHP's IMAGETYPEXXX constants.
exifimagetype() can be used to avoid calls to other exif functions with unsupported file types or in conjunction with SERVER'HTTPACCEPT' to check whether or not the viewer is able to see a specific image in the browser. I also added a ‘file_exists’ check so that you can upload files with the same name as different files on the server – a, , suffix is added to the base filename as needed, and I also do a urlencode on the filename to reduce issues linking to the files. exifimagetype() reads the first bytes of an image and checks its signature.
Imagetype php code#
I went through and ‘cleaned it up’ a little, adding the code for it to use a subdirectory.