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
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)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.