Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Laravel中下载.xlsx文件_Php_Excel_Laravel_Browser_Header - Fatal编程技术网

Php 如何在Laravel中下载.xlsx文件

Php 如何在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',

我在资源中保存了扩展名为.xlsx的文件,但从浏览器下载时它显示为.xls

$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类型,因为某些原因认为它们不同。下载的文件是否已损坏?如果保存并更改扩展名,它会打开吗?