안녕하세요, cakephp의 File :: write()에 이상한 문제가 있습니다.cakephp - 파일 저장 및 첨부 파일로 보내기
나는이 코드를 작성하여 pdf보기를 생성하고 파일에 저장합니다.
private function generate($id){
$order = $this->Order->read(null, $id);
$this->set('order', $order);
$view = new View($this);
$viewdata = $view->render('pdf');
//set the file name to save the View's output
$path = WWW_ROOT . 'ordini/' . $id . '.pdf';
$file = new File($path, true);
//write the content to the file
$file->write($viewdata);
//return the path
return $path;
}
나는
public function publish ($id) {
$pdf_file = $this->generate((int)$id);
$Email = new CakeEmail();
$Email->from(array('[email protected]' => '......'));
$Email->to('[email protected]');
$Email->subject('Nuovo ordine');
$filepath = WWW_ROOT . 'ordini/' . $id . '.pdf';
$Email->attachments(array('Ordine.pdf' => $filepath));
$Email->send('......');
}
내가 이메일이없는 작품 않습니다이 코드를 실행 처음, 이메일이 경우에만 좋은 일이 PDF를 생성하고, 그래서이 내 코드는 attacchment로 보낼 필요 pdf는 폴더에 alredy입니다.
필자는 File :: write가 일종의 비동기 쓰기를 수행하고 시스템이 Email :: attachments 파일을 실행할 때 준비가되지 않았다고 생각합니다.
파일 가용성을 확인하기 위해이 코드에서 while()을 어떻게 삽입합니까?
감사합니다.