This project has moved. For the latest updates, please go here.

diffrentiate b/w zip file and xlsx file

Jan 23, 2014 at 8:43 AM
how do i diffrentiate b/w zip file and xlsx file that is uploaded. I need to restrict uploading of zip file . Zip and xlsx have the same hexadecimal code.
Jan 23, 2014 at 9:33 AM
The problem with .xlsx - is it a ZIP file, zip file with xml documents inside. So there is no way to reliably detect if one is xlsx or zip, because both are zip.
Jan 23, 2014 at 11:43 AM
ok .. thanks a lot .
But how do i detect csv file . any standard hexa value ?
Jan 23, 2014 at 12:28 PM
Pretty much same problem goes to csv file - it is a plain text file, you can open it with a notepad. Csv is not a binary, so can't detect by a binary signature.

This project has been abandoned mostly because there are so many formats that are very hard to detect. You can reliably determine to a certain point, but .zip vs .xlsx or .zip vs .docx - and you are screwed!