【发布时间】:2021-07-31 14:26:34
【问题描述】:
我有一个程序正在生成一个 .csv 文件,然后我想在浏览器中下载。问题是:调用该函数时,文件显示在浏览器中而不是下载它。有什么建议吗?
$csv=array($index,$value);
$filename='persons.xls';
$handle=fopen('persons.xls', 'w');
$headers = ['Content-Type: text/xls'];
foreach ($csv as $row) {
fputcsv($handle, $row);
}
fclose($handle);
return Response::download(public_path('/persons.xls'),'persons.xls',$headers);
【问题讨论】:
标签: excel laravel file download