laravel下载响应文件名未更改



我正在使用laravel并尝试下载一个文件并更改文件名。文档告诉我可以使用第二个参数作为新文件名,但文件名不会以某种方式更改为"testdownload.zip"。我做错了什么?

https://laravel.com/docs/5.8/responses#file-下载

// routes
Route::group(['middleware' => ['web']], function()
{
Route::group(['namespace' => 'AppHttpControllers'], function()
{
Route::group(['middleware' => ['role:root|admin|store|user']], 
function()
{
// download purchase
Route::get('dashboard/order/downloadfile', [
'as'    => 'order-download',
'uses'  => 'PostPostController@download'
]);
});
}
}
// method in Controller
public function download(Request $request)
{
return response()->download(storage_path('app/lorem-ipsum-shop-1.zip'), 'testdownload.zip', ['Content-Type: application/zip']);
}

当我添加(response((->download(storage_path('app/lorem-ipsum-shop-1.zip'(,'testdownload.zip',['Content-Type:application.zip'](时,会返回以下内容(可能是perms/permissions 0100666吗?我在Windows上(:

BinaryFileResponse {#449 ▼
#file: File {#464 ▼
path: "C:xampp71htdocsstorageapp"
filename: "lorem-ipsum-shop-1.zip"
basename: "lorem-ipsum-shop-1.zip"
pathname: "C:xampp71htdocsstorageapp/lorem-ipsum-shop-1.zip"
extension: "zip"
realPath: "C:xampp71htdocsstorageapplorem-ipsum-shop-1.zip"
aTime: 2019-11-14 11:34:52
mTime: 2019-11-14 11:34:52
cTime: 2019-11-01 16:05:10
inode: 0
size: 24626
perms: 0100666
owner: 0
group: 0
type: "file"
writable: true
readable: true
executable: false
file: true
dir: false
link: false
linkTarget: "C:xampp71htdocsstorageapplorem-ipsum-shop-1.zip"
}
#offset: 0
#maxlen: -1
#deleteFileAfterSend: false
+headers: ResponseHeaderBag {#234 ▼
#computedCacheControl: array:1 [▼
"public" => true
]
#cookies: []
#headerNames: array:5 [▼
0 => 0
"cache-control" => "Cache-Control"
"date" => "Date"
"last-modified" => "Last-Modified"
"content-disposition" => "Content-Disposition"
]
#headers: array:5 [▼
0 => array:1 [▶]
"cache-control" => array:1 [▶]
"date" => array:1 [▶]
"last-modified" => array:1 [▶]
"content-disposition" => array:1 [▼
0 => "attachment; filename=testdownload.zip"
]
]
#cacheControl: array:1 [▼
"public" => true
]
}
#content: null
#version: "1.0"
#statusCode: 200
#statusText: "OK"
#charset: null
}

始终清除缓存。。。我认为它在重命名之前存储了文件名。

最新更新