Php 如何在Laravel中下载.xlsx文件
我在资源中保存了扩展名为.xlsx的文件,但从浏览器下载时它显示为.xlsPhp 如何在Laravel中下载.xlsx文件,php,excel,laravel,browser,header,Php,Excel,Laravel,Browser,Header,我在资源中保存了扩展名为.xlsx的文件,但从浏览器下载时它显示为.xls $path = $processor->process($result->toArray(), 'test.xlsx'); $headers = [ 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
$path = $processor->process($result->toArray(), 'test.xlsx');
$headers = [
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Length' => filesize($path),
'Cache-Control' => 'must-revalidate',
'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' => 'attachment; filename="test.xlsx"'
];
return response()->download($path, 'test.xlsx', $headers);
所有的网络浏览器还是一些边缘问题?我用的是chromeFWIW:在谷歌看到很多结果。看起来确实发生了很多事。。。Windows试图保护您。此线程中提供的解决方案无法解决我的问题,因为我在代码中已经有此meme类型,因为某些原因认为它们不同。下载的文件是否已损坏?如果保存并更改扩展名,它会打开吗?