mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-29 22:45:14 -04:00
Improves zipped download.
This commit is contained in:
parent
f51a0b80a7
commit
bc6e9fb150
5 changed files with 74 additions and 15 deletions
|
@ -118,12 +118,26 @@ else if ($action === "zip") {
|
|||
$hrefs = explode(":", trim($hrefs));
|
||||
$zipFile = $zipit->zip($hrefs);
|
||||
|
||||
if ($zipFile === false) {
|
||||
fail(2, "something went wrong while building the zip");
|
||||
if ($zipFile) {
|
||||
$response = array('status' => 'ok', 'id' => basename($zipFile), 'size' => filesize($zipFile));
|
||||
} else {
|
||||
$response = array('status' => 'failed', 'msg' => 'none');
|
||||
}
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
|
||||
else if ($action === "getzip") {
|
||||
|
||||
list($id) = checkKeys(array("id"));
|
||||
fail(1, "zipped file not found: " . $id, !preg_match("/^h5ai-zip-/", $id));
|
||||
|
||||
$zipFile = str_replace("\\", "/", sys_get_temp_dir()) . "/" . $id;
|
||||
fail(2, "zipped file not found: " . $id, !file_exists($zipFile));
|
||||
|
||||
header("Content-Disposition: attachment; filename=\"h5ai-selection.zip\"");
|
||||
header("Content-Type: application/force-download");
|
||||
// header("Content-Type: application/force-download");
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Length: " . filesize($zipFile));
|
||||
header("Connection: close");
|
||||
readfile($zipFile);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue