Forum Moderators: coopster

Message Too Old, No Replies

Upload ZIP File

         

ayushchd

9:23 am on Sep 27, 2009 (gmt 0)

10+ Year Member



Guys,

I need to upload ZIP files through PHP. Is it possible?
If yes, how can i check the file type is ZIP or RAR..

Like for images, we can check by
$_FILES["uploaded"]["type"] == "image/gif"

Waiting for replies.

rocknbil

4:54 pm on Sep 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried setting up a test and adding

echo $_FILES['uploaded']['type'];

To see if it recognizes the file type?

Per the documentation [us2.php.net] it's the browser that provides the content type so this may not be a reliable method, but if it works it would be an easy solution.

The only other way I know of to determine a file's exact type is to read it with ImageMagick after upload, and I'm not sure .zip or other non image types are recognized.

optik

9:47 am on Sep 28, 2009 (gmt 0)

10+ Year Member



you can just check the file name extension or are you concerned about people changing the extension?

I believe there is a class out there which can check a files header info to see what type of file it is.