我有一个 Laravel 应用程序,它应该能够csv
向/从我的服务器端数据库上传和下载文件。它在我的本地开发环境中运行良好,但是当我将它部署到 Vultr.com 上的生产服务器时。我的下载不起作用。上传 csv 仍然可以正常工作。
如果我单击网络上的下载按钮。
在 Chrome 中,它返回
无法访问此站点... ERR_INVALID_RESPONSE
在Firefox中,它返回
文件未找到..
在 Edge(IE) 中,它将下载一个 0 字节的部分文件。
我的本地开发环境是: LEMP+PHP5.6+Laravel 5.3
我的生产服务器环境是: Ubuntu 16.10+nginx/1.10.1 (Ubuntu)+php7.0+Laravel5.3。我还测试将 PHP 从 7.0 降级到 5.6。问题依然存在。
我在网上做了一些研究,似乎这个问题与 php-zip, php-gd modules their correct versions 有关。大多数人抱怨无法下载“xlsx”,但旧的“xls”和“csv”工作正常。我已经尝试过多次以确保我有正确/更新的 php-zip、php-gd 版本与我的 php.ini 相关联。仍然没有运气。我的出口控制器代码为:
return Excel::create('templete', function($excel) use ($data) {
$excel->sheet('rateTemplete', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download($type); //here $type =csv
//$data was the table generate from the databse,
//I can use dd($data) before the Excel call to make sure it is alright.
有人对此有任何想法吗?