Jump to content

Archived

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

eliteskills

Unzip file with php

Recommended Posts

I'd like to unzip a file automatically in php.


If I run unzip.php which contains
[code]<? system('unzip -o xml.zip')[/code]

It works in ssh, but it does nothing if I just go directly to the file unzip.php on my server through http request on firefox.





How do I set the permissions so that it allows me to unzip the file just by going to the php page?

Share this post


Link to post
Share on other sites
These are probably restricted by your webserver.

You should really contact the web hosting company.

If your server has cPanel installed, you can use its built-in Zip extractor.

Share this post


Link to post
Share on other sites
[!--quoteo(post=383068:date=Jun 12 2006, 09:05 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 12 2006, 09:05 PM) [snapback]383068[/snapback][/div][div class=\'quotemain\'][!--quotec--]
These are probably restricted by your webserver.

You should really contact the web hosting company.

If your server has cPanel installed, you can use its built-in Zip extractor.
[/quote]


I have a dedicated server with no cpanel. I can unzip things, just not automatically in a shell script

Share this post


Link to post
Share on other sites
Maybe you could try dumping the output into a variable to see if any errors were returned?
[code]system("unzip -o xml.zip",$output)
echo $output;[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=383229:date=Jun 13 2006, 10:30 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 13 2006, 10:30 PM) [snapback]383229[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Maybe you could try dumping the output into a variable to see if any errors were returned?
[code]system("unzip -o xml.zip",$output)
echo $output;[/code]
[/quote]

You'd need to use -p to pipe to stdout, if you use exec instead $output will be an array, you can implode it with "\n" to make it a string again, but if it's php source it wont render to the browser screen, something php does for safety. This way you will have closer control of the archive by bringing it into your process. If you don't want to do this then make sure that the archive is being addressed correctly and then know where the unzipped file is being written to, maybe you just lost it

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.