【发布时间】:2016-02-04 12:53:00
【问题描述】:
我有以下路线:
Route::get('/download/{id}/{filename}', function($id, $filename)
{
// Check if file exists in app/storage/file folder
$file_path = storage_path() .'/orders/'.'/'.$id.'/'. $filename;
if (file_exists($file_path))
{
// Send Download
return Response::download($file_path, $filename, [
'Content-Type: application/vnd.ms-excel; charset=utf-8'
]);
}
else
{
// Error
exit('Requested file does not exist on our server!');
}
})->where('filename', '[A-Za-z0-9\-\_\.]+');
在 Laravel 中下载一个 excel 文件形式 /app/storage (之前上传)。 我面临的问题是下载的excel文件无法被excel读取。如果我从 FTP 下载上传的文件就可以了。我为 Content-Type 尝试了所有类型的标题,但似乎没有任何效果。 excel文件有特殊的标题吗? 非常感谢。
【问题讨论】: