我在我的windows10机器上运行Xampp,在我的目录项目中有一个名为files.txt的文件。
...storage\app\public
我的config/filesystem.php看起来像这样:
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'permissions' => [
'file' => [
'public' => 0664,
'private' => 0600,
],
'dir' => [
'public' => 0775,
'private' => 0700,
],
],
],在我的控制器上,我调用要下载的文件
return response()->download(storage_path("app\public\\files.txt"),'down.txt');我收到200 status Ok,我收到的报头内容:
Content-Disposition: attachment;filename=files.txt,在浏览器上的响应Xhr devtools我可以看到文件的内容,但不高兴下载没有发生。
发布于 2020-09-17 08:09:22
您是否可以尝试指定header:
$content = storage_path("app\public\files.txt");
$fileName = 'down.txt';
$headers = [
'Content-type' => 'text/plain',
'Content-Disposition' => sprintf('attachment; filename="%s"', $fileName),
'Content-Length' => strlen($content)
];
return response()->download($content,$fileName, $headers);https://stackoverflow.com/questions/63929309
复制相似问题