mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 07:04:57 +00:00
add code for downloading file into contoller
This commit is contained in:
parent
da0b3e71b3
commit
46dc4ea6e3
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user