Getting file type
I am in need to get the file type of the given file. I mean whether the given file is jpg or bmp or doc or xls. Please donot suggest me to check the file extension. (There might be a chance to change the extension of a doc file to jpg).
Thanks in Advance
Read file headers, as in the binary data that is stored within the first X bytes of the file.
You mean first 10 bytes of the file?.
Originally Posted by MrCoder
For example I believe the first 4 bytes of some formatted wave files start with "RIFF"
I thought X -> 10 (Roman indication).
Is there any unique format in representing the file formats, so that i can able to read the bytes and get the type of the file.
Look at this page, some very useful ones listed here.
There is also a very good list here
You could also, if hosted on Linux, use the "file" command.
/path/to/my/file/myfile.php: PHP script text
Last edited by MrCoder; 12-19-2007 at 08:48 AM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)