감사합니다. 이런 식으로 뭔가가 :
물론
public function viewpdfAction()
{
$id = (int) $this->_getParam('id', 0);
// You implement some function - either here in your controller
// or someplace else - to get the pdf name from the passed id.
// Alternatively, you can pass the name itself. Up to you, of course.
// The key is that the request somehow identifies the file requested.
$pdfName = $this->_mapPdfIdToName($id);
// The path to the real pdf
$pdfFile = '/project/data/uploads/pdf/' . $pdfName;
// Disable rendering
$this->_helper->viewRenderer->setNoRender(true);
// Send the right mime headers for the content type
$this->getResponse()
->setBody('')
->setHeader('Cache-control', 'public') // needed for IE, I have read
->setHeader('Content-type', 'application/pdf')
->setHeader('Content-Disposition', sprintf('attachment; filename="%s"', $pdfName));
// Send the content
readfile($pdfFile);
}
,이 중 일부는 가능한 한 얇은 컨트롤러를 유지하기 위해 서비스 클래스로 푸시 다운 할 수 있습니다. 이 점에서 모든 사람들은 서로 다른 취향을 가지고 있습니다.
나는이 코드가 완전히 테스트되지 않았다고 고백하며, 대부분 기본 아이디어를 제공하려고합니다. 여기에 총 뼈대 오류가 발생하면 알려주십시오.
희망이 있습니다.
업로드 폴더의 권한을 올바르게 설정 했습니까? – Marcin