Jump to content

Opening a zip + checking for file types?


hlstriker

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!
Link to comment
https://forums.phpfreaks.com/topic/18004-opening-a-zip-checking-for-file-types/
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)

Archived

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

×
×
  • Create New...

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.