Hello i am just creating a zip file using php but the file not being created however it is return boolean true i dont know whats problem going on. before created what did i do
i installed php zip in my Ubuntu using sudo apt-get install php-zip
and after installation i restarted my apache server.
create a zip.php file file and write this code
$zip = new ZipArchive;
//var_dump($zip->open('test.zip',ZipArchive::CREATE));
$f = $zip->open('zip/myzip.zip',ZipArchive::CREATE);
var_dump($f);
this code return true but file not being created
Empty Zip can not be created, You have to select some files to create a zip file. Try below code
$zip = new ZipArchive();
$filename = "test.zip";
if ($zip->open($filename, ZipArchive::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
$zip->addFile("a.jpg","b.jpg");
$zip->close();
replace 'a.jpg', 'b.jpg' from your files.