views:

33

answers:

1

Hi all, I am using ASP.NEt MVC . I want to upload .zip files for which I am using html input file upload control on my view. I want only .zip files to be uploaded. I want to check that my .zip contains only two files - both having extensions .txt and one of them having name "start". Can anyone please suggest me about how to check this? How can we assure that the uploaded .zip is really a zipped folder and not any other file having just .zip extension. can we use HttpPostedFileBase.ContentType?

thanks in advance, kaps

A: 

The ContentType is simply filled in by the client browser, so you can't really trust it. The only way is to try & parse the file on the server: use something like SharpZipLib to open the .zip file and confirm that it has two files in it.

Dean Harding