Jump to content


Photo

Opening a zip + checking for file types?


  • Please log in to reply
2 replies to this topic

#1 hlstriker

hlstriker
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 19 August 2006 - 02:19 AM

Hi, is there a way I can open up a zip file and check for file extensions before it uploads to my server?

For example: I click browse, find my file, push ok. Now I push my Submit button and it runs my php code to upload to file to my database.

I just need to have it check to see if it is a .zip file, and then open the zip and see if only one type of file is inside it (.txt file for exaple), and if anything other than a .txt is inside it will give an error and not upload.

If anyone can help me out that would be great. Thanks!

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 19 August 2006 - 02:26 AM

In order for php to do anything with the file it must be uploaded.  PHP is a server side technology.

In order to do what you are wanting, you can use one of the libraries located at phpclasses.org:

http://www.phpclasse...e/class/42.html

to unzip the file to a location, then check each file that was unzipped using the dir functions (http://www.php.net/dir)

#3 hlstriker

hlstriker
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 19 August 2006 - 04:45 PM

Thanks hitman6003, now does anyone know if there is a virus scan library out there. I searched at phpclasses.org but didn't find anything. I need to scan the files being uploaded for viruses and malware.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users