Thursday, July 30, 2009

How can i find out the file type mime format?

When i upload a file in IE, it shows the file type as Application-octet-stream or plain/text or plain/xml or plain/html even if i change the extention. How to find this format of the file thru c++

How can i find out the file type mime format?
Using first few bytes of the file.





1. For HTML file it will start with





%26lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"





or


%26lt;htm%26gt;%26lt;head%26gt;





2. For exe file, it will have exe header .





3. for .Doc file , it starts with ÐÏ





4. For text file, if none of the above matches, it will be text file





For these details, open the exe or .doc file in notepad , u can see that first few characters/bytes of all .doc file will be same or first few bytes of .exe will be same. use that to differentiate between files.
Reply:sory frd, no idea


No comments:

Post a Comment