>How can I detect the file type of a file? I am trying to know if a file uploaded is in a JPG format.
Check the first few bytes of the file!
JPG starts with FF-D8-FF-00 (hex) or chr(255)+chr(216)+chr(255)+chr(0)
GIF starts with GIF (plain text)
PNG starts wiyh 89-50-E4-47 (hex) which is chr(37)+'PNG'