Jump to content


Photo

Unzip file with php


  • Please log in to reply
4 replies to this topic

#1 eliteskills

eliteskills
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 June 2006 - 01:41 AM

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


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

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?
www.eliteskills.com

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 13 June 2006 - 02:05 AM

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.
~ D Kuang

#3 eliteskills

eliteskills
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 13 June 2006 - 02:12 AM

[!--quoteo(post=383068:date=Jun 12 2006, 09:05 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 12 2006, 09:05 PM) View Post[/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
www.eliteskills.com

#4 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 13 June 2006 - 12:30 PM

Maybe you could try dumping the output into a variable to see if any errors were returned?
system("unzip -o xml.zip",$output)
echo $output;


#5 <?=$humour?>

<?=$humour?>
  • Members
  • Pip
  • Newbie
  • 6 posts
  • LocationBrisbane, AU

Posted 13 June 2006 - 01:13 PM

[!--quoteo(post=383229:date=Jun 13 2006, 10:30 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 13 2006, 10:30 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Maybe you could try dumping the output into a variable to see if any errors were returned?
system("unzip -o xml.zip",$output)
echo $output;
[/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
What I'd like to see:
- I'd like to see a PHP code checker that has the following line:
55 errors in 13 lines; error thrown [PHP_ERROR_SOD_OFF]; PHP has decided you're too stupid to use it, reformatting hard drive ( \ ).





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users