I am a very water web application ape, basically did not write any project. A look at the problem is also very water, but in the internet for a long time, also did not find the answer, I hope the heroes do not spray me.
The environment is as follows:
- ArchLinux 3.16.3
- Apache 2.4.10
- PHP 5.6.0
The requirement is to select from the page, download the zip file from other places to the server, then unzip the output to the client. In the writing process, there is a doubt that the fwrite
files written to/tmp/xx.zip are not visible to the ordinary users on the server. Simply use
exec('ls /tmp/*.zip', $result);print_r($result);
Can be displayed, and by file_get_contents
way of means to ensure that the file does exist.
The problem now is that the zip extension has been enabled in php.ini and it is also possible to execute the following code locally:
$zip = zip_open($target);if($zip) { while($entry = zip_read($zip)) { echo zip_entry_name($entry) . ': ' . zip_entry_filesize($entry) . '/' . zip_entry_compressedsize($entry) . ', by' . zip_entry_compressionmethod($entry) . "\n"; } zip_close($zip);}
Note that local execution, that is php file.php
, but placed in the Apache directory, is not accessible through the browser. Error message:PHP Fatal error: Call to undefined function zip_open()
Reply content:
I am a very water web application ape, basically did not write any project. A look at the problem is also very water, but in the internet for a long time, also did not find the answer, I hope the heroes do not spray me.
The environment is as follows:
- ArchLinux 3.16.3
- Apache 2.4.10
- PHP 5.6.0
The requirement is to select from the page, download the zip file from other places to the server, then unzip the output to the client. In the writing process, there is a doubt that the fwrite
files written to/tmp/xx.zip are not visible to the ordinary users on the server. Simply use
exec('ls /tmp/*.zip', $result);print_r($result);
Can be displayed, and by file_get_contents
way of means to ensure that the file does exist.
The problem now is that the zip extension has been enabled in php.ini and it is also possible to execute the following code locally:
$zip = zip_open($target);if($zip) { while($entry = zip_read($zip)) { echo zip_entry_name($entry) . ': ' . zip_entry_filesize($entry) . '/' . zip_entry_compressedsize($entry) . ', by' . zip_entry_compressionmethod($entry) . "\n"; } zip_close($zip);}
Note that local execution, that is php file.php
, but placed in the Apache directory, is not accessible through the browser. Error message:PHP Fatal error: Call to undefined function zip_open()
Local execution no problem, with URL Access said the function does not exist, the CLI environment and Apache is not a PHP.
Find the PHP location of the CLI environment to see if it is consistent with the mod_php location, if it is consistent, please:
Restart Apache.