Laravel 4.2 应用程序:导出 csv 文件时出现问题
Laravel 4.2 applictaion: issue while exporting csv file
我想将一些数据(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: exception
'Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException'
with message 'The file
"/var/www/html/FootballTicketPad/geethu/bondcms/app/storage/transactions/we1_2018-03-20.csv"
does not exist' in
/var/www/html/FootballTicketPad/geethu/bondcms/vendor/symfony/http-foundation/File/File.php:37
是权限问题
cd storage
chmod -Rv 777 transcations
我想将一些数据(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: exception 'Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException' with message 'The file "/var/www/html/FootballTicketPad/geethu/bondcms/app/storage/transactions/we1_2018-03-20.csv" does not exist' in /var/www/html/FootballTicketPad/geethu/bondcms/vendor/symfony/http-foundation/File/File.php:37
是权限问题
cd storage
chmod -Rv 777 transcations