PHP Zip function doesn't work (Debian, Apache, PHP5) -


i've installed apache on debian server , added php. if try create .zip file doesn't work. there's no error message .zip file doesn't created.

code:

<?php $zip = new ziparchive; $res = $zip->open('test.zip', ziparchive::create); $zip->addfile('banner1.png', 'banner1.png'); $zip->close(); ?> 

most likely, user php running (on debian, www-data default) doesn't have writing permissions directory. check result of various functions this:

<?php $zip = new ziparchive(); $res = $zip->open('test.zip', ziparchive::create); if (!$res){     echo 'error while creating zip file: ' . $zip->getstatusstring();     exit(); } if (! $zip->addfile('banner1.png', 'banner1.png')) {     echo 'error while adding banner1: ' . $zip->getstatusstring();     exit(); } if (! $zip->close()) {     echo 'error while closing: ' . $zip->getstatusstring();     exit(); } 

on debian default configuraiton, can configure permissions chown , chmod. example, allow webserver write directory, try

sudo chown www-data /path/to/directory/with/php/file sudo chmod u+rwx /path/to/directory/with/php/file 

Comments