Zip Multiple file Than unlink the file
<?php
$direc = base64_decode($_GET['path']);
$zip = new ZipArchive();
if ($zip->open($archive_file_name, ZIPARCHIVE::CREATE) !== TRUE) {
exit("cannot open <$archive_file_name>\n");
}
//add each files of $file_name array to archive
foreach ($file_names as $files) {
$zip->addFile($file_path . $files, $files);
}
$zip->close();
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=" . $archive_file_name);
header('Cache-control: private, must-revalidate');
header('Content-Transfer-Encoding: binary');
readfile("$archive_file_name");
exit;
}
if (isset($_POST['file'])) {
$file_na开发者_运维技巧mes = $_POST['file'];
$archive_file_name = 'zipped.zip';
$file_path = $direc;
echo $file_path;
//Run Function above
zipFilesAndDownload($file_names, $archive_file_name, $file_path);
if (file_exists($archive_file_name)) {
unlink($archive_file_name);
}
?>
I find code above and try it, The zip file created but statement unlink($zipname);
doesn't work
I don't have any problem about permission
Is that file strill write-protected? How to solve that problem?
Thanks Friends
Your function above should call return, not exit. Exit terminates execution of the script, so nothing after that will be called. It's probably not even getting to the file_exists part.
精彩评论