Ouzo\DownloadHandler::downloadFile PHP Method

downloadFile() public method

public downloadFile ( array $fileData )
$fileData array
    public function downloadFile(array $fileData)
    {
        header('Content-Type: ' . $fileData['mime']);
        header('Content-Disposition: attachment; filename="' . $fileData['label'] . '"');
        readfile($fileData['path']);
    }

Usage Example

Beispiel #1
0
 private function _doActionOnResponse()
 {
     $controller = $this->currentControllerObject;
     $this->_sendHeaders($controller->getHeaders());
     $this->cookiesSetter->setCookies($controller->getNewCookies());
     switch ($controller->getStatusResponse()) {
         case 'show':
             $this->renderOutput();
             break;
         case 'redirect':
             $this->_redirect($controller->getRedirectLocation());
             break;
         case 'redirectOld':
             $this->redirectHandler->redirect($controller->getRedirectLocation());
             break;
         case 'file':
             session_write_close();
             $this->downloadHandler->downloadFile($controller->getFileData());
             break;
         case 'stream':
             session_write_close();
             $this->downloadHandler->streamMediaFile($controller->getFileData());
             break;
     }
 }