2013-10-17 2 views
0

파일 downloads과 관련된 설명서를 읽었지만 제대로 작동하지 않습니다.다운로드 기능이 작동하지 않습니다. CakePHP

나는 또한 readthroughquestionshere을 가지며 행운이 없다.

내 기능은 다음과 같습니다

public function generate($id) { 
    $this->layout = 'ajax'; 
    $this->Magazine->recursive = 2; 
    $DistributionLists = $this->Magazine->DistributionList->find('all', 
     array(
      'conditions' => array(
       'Magazine.id' => $id 
      ), 
      'order' => array(
       'DistributionList.priority ASC' 
      ) 
     ) 
    ); 
    $this->set('magazine',$DistributionLists[0]['Magazine']['magazine_name']); 
    $this->set(compact('DistributionLists')); 
} 

public function download() { 
    $this->viewClass = 'Media'; 
    $params = array(
     'id'  => "Magazine Distribution List.doc", 
     'name'  => "Magazine Distribution List", 
     'download' => true, 
     'extension' => 'doc', 
     'path'  => APP . "tmp" . DS 
    ); 
    $this->set($params); 
    unlink(APP."tmp".DS); 
    $this->redirect(array('action'=>'index')); 
} 

public function afterFilter() { 
    parent::afterFilter(); 
    if($this->action == 'generate') { 
     $this->redirect(array('action'=>'download')); 
    } 
} 

I 다운로드 할 필요가있는 워드 문서보기 파일에 생성됩니다 때문에 afterFilter 기능이있는 이유.

왜 이것이 작동하지 않는지 아는 사람이 있습니까?

+0

항상 정확한 CakePHP 버전을 언급하십시오! – ndm

+1

아마도 다운로드 방법에서 리디렉션을 제거해야합니다. – dhofstet

+0

오류가 있습니까? 무엇이 일어나고 있지 않습니까? ... etc – Dave

답변

1

download 메서드에서 redirect 메서드에 대한 호출을 제거해야하므로 리디렉션으로 인해 뷰가 "렌더링"되지 않습니다.

관련 문제