View Full Version : Unzip archive using PHP
ishunko
08-05-2005, 12:17 PM
Hello,
I'd like to unpack a ZIP archive using PHP script. Sounds like a simple task, I tried:
<?php
system("unzip archive.zip");
?>
However, it doesn't work. The output is 'Archive: archive.zip' and nothing is unzipped.
At the same time 'unzip archive.zip' works fine in shell...
Can anyone help me resolve this problem? Thanks.
iDxMan
08-06-2005, 02:22 PM
Might be some kind of safe_mode thing that limits shell execution. (no clue, just a general guess) Although you can use the PEAR::Archive_Zip (http://pear.php.net/package/Archive_Zip) class.
-r
ishunko
08-06-2005, 09:26 PM
you can use the PEAR::Archive_Zip (http://pear.php.net/package/Archive_Zip) class.
-r
Thanks, I'll give it a try
ishunko
08-07-2005, 10:14 AM
Looks like Archive_Zip class is not available... :(
iDxMan
08-07-2005, 02:04 PM
You mean not available by default on HR servers? That would be my assumption as well.
I would download it manually and place it somewhere under your own directory so you can include it.
(CVS link: http://cvs.php.net/cvs.php/pear/Archive_Zip )
-r
Whiteknight
08-07-2005, 02:47 PM
make sure that you have access priveledges to archive.zip. if you don't have the right access privledges, unzip wont be able to perform the right tasks. if unzip has an error log file, check that out, and see if it is giving you any permissions problems.
ishunko
08-07-2005, 08:17 PM
There must be somethig wrong either with me or the server :)
I have downloaded the Pear class as you suggested, created a very simple page that was supposed to create a zip archive and nothing worked... No error messages, nothig... Here is my code:
<?
require('zip.php');
$zip = new Archive_Zip('new.zip');
$arr = array('file1.txt', 'file2.txt');
$zip->create($arr);
?>
Can anyone please give the some simple code that actually works on the HR server? I'd try it on my server and see if there is a problem with permissions or something...
Thanks!
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.