public downloadFile ( $fileId, $inline = false ) : boolean | ||
$fileId | int the file id of the file to download | |
$inline | print file as inline instead of attachment, optional | |
Результат | boolean |
function downloadFile($fileId, $inline = false)
{
$issueFileDao = DAORegistry::getDAO('IssueFileDAO');
$issueFile = $issueFileDao->getById($fileId);
if ($issueFile) {
$fileType = $issueFile->getFileType();
$filePath = $this->getFilesDir() . $this->contentTypeToPath($issueFile->getContentType()) . '/' . $issueFile->getServerFileName();
return parent::downloadFile($filePath, $fileType, $inline);
} else {
return false;
}
}
/** * An action to download an issue galley * @param $args array * @param $request PKPRequest * @return string Serialized JSON object */ function download($args, $request) { $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE); $issueGalley = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE_GALLEY); import('classes.file.IssueFileManager'); $issueFileManager = new IssueFileManager($issue->getId()); return $issueFileManager->downloadFile($issueGalley->getFileId()); }