BxDolTwigModule::_actionDownload PHP Method

_actionDownload() public method

public _actionDownload ( $aFileInfo, $sFieldMediaId )
    function _actionDownload($aFileInfo, $sFieldMediaId)
    {
        $aFile = BxDolService::call('files', 'get_file_array', array($aFileInfo[$sFieldMediaId]), 'Search');
        if (!$aFile['date']) {
            $this->_oTemplate->displayPageNotFound();
            exit;
        }
        $aFile['full_name'] = uriFilter($aFile['title']) . '.' . $aFile['extension'];
        $aPathInfo = pathinfo($aFile['path']);
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Content-type: " . $aFile['mime_type']);
        header("Content-Length: " . filesize($aFile['path']));
        header("Content-Disposition: attachment; filename={$aFile['full_name']}");
        readfile($aFile['path']);
        exit;
    }

Usage Example

コード例 #1
0
 function actionDownload($iFileId)
 {
     $aFileInfo = $this->_oDb->getFileInfoByFileId((int) $iFileId);
     if (!$aFileInfo) {
         $this->_oTemplate->displayPageNotFound();
         exit;
     }
     if (!$this->isAllowedDownload($aFileInfo)) {
         $this->_oTemplate->displayAccessDenied();
         exit;
     }
     parent::_actionDownload($aFileInfo, 'media_id');
 }
All Usage Examples Of BxDolTwigModule::_actionDownload