cancel
Showing results for 
Search instead for 
Did you mean: 

unzipping files with php

N/A

unzipping files with php

Hi,
I have spent quite a few hours trying to find away to unpack a zip file residing in a write-enabled folder using PHP. I first off went researching the zip and rar functions in PHP, and then realised that force9 doesnt have those modules. I have since been playing with the unzip command which works fine from the shell, but not from PHP.

Im currently using the following code:

<?php

$output = shell_exec('ls -lart');
echo "<pre>$output</pre><br/>\n<br/>\n";

$output = shell_exec('unzip -j temp.zip');
echo "<pre>zip output: \"$output\"</pre><br/>\n<br/>\n";
?>


I run ls first to make sure im in the correct directory. Tantelisingly this has worked once (!), unpacked the single jpg file contained within the archive and placed it in the directory with the owner 'wwwuser', but the rest of the time the output is blank. ls works every time.

If anyone has any suggestions / experience that you care to share it would be much appreciated.

Jarv