gpt4 book ai didi

Laravel 5.4存储: downloading files.文件不存在,但显然它存在

转载 作者:行者123 更新时间:2023-12-02 03:03:11 25 4
gpt4 key购买 nike

我一直在纠结这个问题。我上传的内容如下:

public function store(Tool $tool)
{

If(Input::hasFile('file')){
$file = Input::file('file');
$name = $file->getClientOriginalName();
$path=Storage::put('public',$file); //Storage::disk('local')->put($name,$file,'public');

$file = new File;
$file->tool_id = $tool->id;
$file->file_name = $name;
$file->path_to_file = $path;
$file->name_on_disk = basename($path);
$file->user_name = \Auth::user()->name;
$file->save();

return back();
}

但是当我尝试下载时:

public function show($filename)
{

$url = Storage::disk('public')->url($filename);

///$file = Storage::disk('public')->get($filename);
return response()->download($url);
}

我从 laravel 收到 FileNotFound 异常但是,如果我用这个代替:

$file = Storage::disk('public')->get($filename);
return response()->download($file);

我明白了

FileNotFoundException in File.php line 37: The file "use calib;

insert into notes(tool_id,user_id,note,created_at,updated_at) VALUES(1,1,'windows server 2008 sucks',now(),now());" does not exist

这是文件的实际内容...

显然可以找到该文件。但为什么不下载呢?

最佳答案

试试这个:

return response()->download(storage_path("app/public/{$filename}"));

关于Laravel 5.4存储: downloading files.文件不存在,但显然它存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42116349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com