add code for downloading file into contoller

This commit is contained in:
Uwe Steinmann 2015-06-08 21:59:56 +02:00
parent da0b3e71b3
commit 46dc4ea6e3
2 changed files with 21 additions and 14 deletions

View File

@ -25,10 +25,10 @@ class SeedDMS_Controller_Download extends SeedDMS_Controller_Common {
public function run() {
$dms = $this->params['dms'];
$type = $this->params['type'];
$content = $this->params['content'];
switch($type) {
case "version":
$content = $this->params['content'];
if(!$this->callHook('version')) {
header("Content-Transfer-Encoding: binary");
@ -40,6 +40,23 @@ class SeedDMS_Controller_Download extends SeedDMS_Controller_Common {
readfile($dms->contentDir . $content->getPath());
}
break;
case "file":
$file = $this->params['file'];
if(!$this->callHook('file')) {
header("Content-Type: application/force-download; name=\"" . $file->getOriginalFileName() . "\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($dms->contentDir . $file->getPath() ));
header("Content-Disposition: attachment; filename=\"" . $file->getOriginalFileName() . "\"");
//header("Expires: 0");
header("Content-Type: " . $file->getMimeType());
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: must-revalidate");
//header("Pragma: no-cache");
readfile($dms->contentDir . $file->getPath());
}
break;
}
}
}

View File

@ -100,19 +100,9 @@ if (isset($_GET["version"])) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_file_id"));
}
header("Content-Type: application/force-download; name=\"" . $file->getOriginalFileName() . "\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($dms->contentDir . $file->getPath() ));
header("Content-Disposition: attachment; filename=\"" . $file->getOriginalFileName() . "\"");
//header("Expires: 0");
header("Content-Type: " . $file->getMimeType());
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: must-revalidate");
//header("Pragma: no-cache");
ob_clean();
readfile($dms->contentDir . $file->getPath());
$controller->setParam('file', $file);
$controller->setParam('type', 'file');
$controller->run();
} elseif (isset($_GET["arkname"])) {
$filename = basename($_GET["arkname"]);