Jump to content

Unzip file with php


eliteskills

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?
Link to comment
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
Link to comment
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
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.