Laravel文件下载“文件不常用下载”

时间:2018-09-01 17:29:47

标签: php laravel

我在Laravel下载文件时遇到一些问题。我很确定这与Laravel无关。问题是,当我尝试下载自己上传的文件时,会发出“该文件通常不下载”的警告。我不确定为什么会这样。这是我的代码。

下载

public function show($id)
{
    $download = Download::findOrFail($id);
    return Storage::download(Download::FILES_DIRECTORY . '/' . $download->file);
}

上传

public function store(Request $request)
{
    $this->validate($request, [
        'file' => 'required|file|max:40000'
    ]);

    $file = $request->file('file');
    $fileName = Str::random(30) . '.' . $file->getClientOriginalExtension();
    Storage::putFileAs(Download::FILES_DIRECTORY, $file, $fileName);

    $download = new Download();
    $download->file = $fileName;
    $download->save();

    return back()->with('success', 'File uploaded.');
}

请求标头

Host: ionclient.xyz
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://ionclient.xyz/dashboard
Cookie: XSRF- TOKEN=eyJpdiI6Ik9nQUJCODlDcnpGcDVQXC9meHNNRlF3PT0iLCJ2YWx1ZSI6IkllNlpybkZ2bXZwQytYcG00MzFqa2tkcDRcL1NJamFuSDNXNzhZZTNOVkVHNllBWVEyV3EzaEs2WVMwa3NHZUdsIiwibWFjIjoiYzVlY2NhOGMzNjZiN2ZjOWRjMGE2ZTgzZTI1NGYyNmU4ZDU1MDUzY2FhZDQzMDEzZjI2YTI4ZGU1ZjIwOTBiNSJ9; ion_client_session=eyJpdiI6IjBpWlVsaXgxQVpDTVdCVjgrRHZuOVE9PSIsInZhbHVlIjoiWnNuemFxaStKdmlhK2dxMXppempKc1YwSm9IRkR0R0JLZzJzUVlpVXNZK2w2U3BvYm01aFIrQkxUc0hXckxrRCIsIm1hYyI6IjIwYjY1MTllYmNkOWJmNDM4ODJkNjY0ZjJjNTU2YzVmNDg4YTFmMGZhNWExMWM0MDYzMmI1Y2YzNWZiNjg0NjIifQ%3D%3D
Connection: keep-alive
Upgrade-Insecure-Requests: 1

响应头

HTTP/2.0 200 OK
date: Sat, 01 Sep 2018 17:25:49 GMT
server: Apache
x-powered-by: PHP/7.2.9
content-disposition: attachment; filename=LMJgPLybBbZg1PiSpSJRAdWbH69bGF.zip
cache-control: no-cache, private
set-cookie: XSRF-TOKEN=eyJpdiI6Ik9iTENwOWlydkNJSTlkNmVoNm10SGc9PSIsInZhbHVlIjoiUG9ZQXNcL0k2dmlJZlVSZUpDUlZMU0JzMzNPWUZNTVpJSUs5XC85UnhRSFVLQUVDYmxKcXJQeTNIMVIxdjExNCtoIiwibWFjIjoiNzIwNWVjNmE3NzEwYmJiZjRjYzdlZmYzYTNmNmQwMDNlZjFmZmI4M2RmOTVmYTM4NTI1ZDA5ZDNlZGJmNzM0YiJ9; expires=Sat, 01-Sep-2018 19:25:50 GMT; Max-Age=7200; path=/
set-cookie: ion_client_session=eyJpdiI6IlVlWWJOa1FNOE8yeVIzamo4M2c5VEE9PSIsInZhbHVlIjoid3R0QTZ0bEV3R1FXRzMwSUlcL0NDZGxEd1wveDFrZzdSWVRSejFDQkpaWVMrajVqNDJlNmZjUE9sWklPbHNrM2ZMIiwibWFjIjoiYTVhOGQ0NDg1ODY3MWU3MDBlYmFlYzA2MWYxYjQwMzhmMWExOGFlNWRjNDkyZTJhMjA0MTU1ZWVmZjhlOGZhYyJ9; expires=Sat, 01-Sep-2018 19:25:50 GMT; Max-Age=7200; path=/; httponly
content-length: 4216
content-type: application/zip
X-Firefox-Spdy: h2

1 个答案:

答案 0 :(得分:0)

在Google抓取工具验证我的网站后修复。