diff --git a/controllers/class.Download.php b/controllers/class.Download.php index 36d7b8186..577db2740 100644 --- a/controllers/class.Download.php +++ b/controllers/class.Download.php @@ -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; } } } diff --git a/op/op.Download.php b/op/op.Download.php index 483a8e427..3d5453873 100644 --- a/op/op.Download.php +++ b/op/op.Download.php @@ -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"]);