CakePHP3でViewからPOSTしたデータをzip化してブラウザにダウンロードするプログラムを作成しております。実際に動かすとうんともすんともしないので困っております。何かアドバイスを頂きたいです。
error_log等を利用してすべてソースは通ることは確認しております。
参考元
https://qiita.com/kazu56/items/5667f963624b603f9277
宜しくお願いします。
if ($this->request->is('ajax')) { $data=$this->request->getData(); $zip=new \ZipArchive(); $zip->open(FILEPATH . 'download.zip', \ZipArchive::CREATE); // POSTしたファイルのPATHを渡して、zip化しています。 foreach ($data as $d) { $file_name=basename($d); if (!empty($file_name)) { $zip->addFile($d, $file_name); } } $zip->close(); $this->response->file( FILEPATH . 'download.zip', [ 'name'=>'download.zip', 'download'=>true, ] ); echo $this->request->is(['ajax']); exit; }