2012-06-25 2 views
1

젠드 프레임 워크 PHP 애플리케이션에서 브라우저로 파일을 보내려고합니다. 내 파일을 내 공용 폴더 즉 MyApp를/공공/다운로드/myFile.pdfPHP - Zend Framework send file

에 위치한이

public function downloadfileAction() 
{ 
    //get the file name and strip out all white spaces 
    $title = preg_replace('/\s+/', '', $this->getRequest()->getParam('title')); 

    //create the file path   
    $path = 'downloads/'.$title.'.pdf'; 

    //call the action helper to send the file to the browser 
    $this->_helper->SendFile->sendFile($path, 'application/x-pdf'); 
} 

같은 작업을 https://github.com/noginn/noginn/blob/master/Noginn/Controller/Action/Helper/SendFile.php

내 컨트롤러에서 - 여기 작업 도우미 발견 작업을 실행하면보기 파일을 찾을 수 없으며 다운로드가 시작되지 않습니다.

exception 'Zend_View_Exception' with message 'script 'myController/downloadfile.phtml' not found ... 

누구든지 내가 뭘 잘못하고 있다고 제안 할 수 있습니까?

답변

2

script- (view) -file에서 찾을 수없는 내용입니다. 출력을 보낼 때 필요하지 않기 때문입니다.

이 이것에 의해 비활성화 시도 :

public function downloadfileAction() 
{ 
    //get the file name and strip out all white spaces 
    $title = preg_replace('/\s+/', '', $this->getRequest()->getParam('title')); 

    //create the file path   
    $path = 'downloads/'.$title.'.pdf'; 

    //call the action helper to send the file to the browser 
    $this->_helper->SendFile->sendFile($path, 'application/x-pdf'); 
    $this->_helper->viewRenderer->setNoRender(); 
} 
+0

브릴리언트, 즉 일! 감사. –

+0

잘 듣고, 아무런 문제가 없습니다! :) 답변을 수락하는 것을 잊지 마세요, 감사합니다. :) – Ronn0