tags:

views:

142

answers:

4

can any one please let me know, why i could not get result for the php function

exec('unzip gallery.zip',$return);
print_r($return);
A: 

$return is an array

Sres
A: 

Have you initialized variable $return before use?

Have you installed package unzip if you're running Unix or Linux? (I'm not sure that you can do that on Windows)

abatishchev
Hi, do i need to enable any commend in php.ini?
VAC-Prabhu
+2  A: 

Did you check the return value from unzip? Error messages are not given on standard output stream, so the array will be empty if something fails.

<?php
    $result = array();
    exec("unzip archiv.zip", $result, $returnval);
    print_r($result);
    print_r($returnval);
?>

Does the unzip work as expected? It might ask for overwriting etc. if the files already exist and stop the workflow. This output will not be captured in the result.

Eiko
A: 

Errors are written to stderr and aren't shown when using exec, backticks or shell_exec functions.

passthru() does output the error stream (as well as stdout).

Ps : Its probably either:

File not found: Does gallery.zip exists in the cwd. Use absolute paths and escapeshellarg() te be sure.

or

File rights: Is php allowed to write the extracted files to the cwd or specified targetpath?

Bob Fanger