我想将一些数据(laravel集合)导出为csv文件。
public function exportTransaction()
{
$ticket=all();
$filename=$customer['firstname']."_".date('Y-m-d').".csv";
$file_path=storage_path(). "/transactions"."/".$filename;
$handle = fopen($file_path,"w+");
fputcsv($handle, array('date'));
foreach($ticket as $row) {
fputcsv($handle, array($row['orderDate']));
}
fclose($handle);
$headers = array(
'Content-Type' => 'text/csv',
);
return Response::download($file_path, $filename, $headers);
}
这是我的代码。我收到此错误
local.ERROR:异常 ' Symfony的\元器件\ HttpFoundation \文件\异常\ FileNotFoundException异常' 与消息'文件 " /var/www/html/FootballTicketPad/geethu/bondcms/app/storage/transactions/we1_2018-03-20.csv" 不存在'在 /var/www/html/FootballTicketPad/geethu/bondcms/vendor/symfony/http-foundation/File/File.php:37
答案 0 :(得分:0)
这是许可问题
cd storage
chmod -Rv 777 transcations