Jump to content

Archived

This topic is now archived and is closed to further replies.

hlstriker

Opening a zip + checking for file types?

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.phpclasses.org/browse/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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.