0
試圖下載一個csv文件,在下載過程中,頁面在新標籤中打開,並在File.php第37行中顯示爲FileNotFoundException
的錯誤:文件「72」不存在。任何人都可以幫我嗎?無法下載laravel 5中的文件?
Laravel控制器:
public function fileExport(Request $request, Response $response)
{
$employee = Employee::all()->toArray();
$fileName = 'Employee.csv';
$headers = array(header('Content-Type: application/csv', 'Content-Disposition: attachment; filename="'.$fileName.'"'));
$f = fopen('php://output', 'w');
foreach ($employee as $line)
{
$data = fputcsv($f, $line);
}
return response()->download($data,$headers);
}
Laravel路由器:
Route::get('fileExport', '[email protected]');
Angularjs控制器:
$scope.exportFile = function(){
$window.open(rootUrl+'fileExport');
}
<button class="btn btn-default btn-xs btn-detail" ng-click="exportFile()">Export</button>