我一直在为这件事转来转go .我有上传工作与以下工作:
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();
}
但是,当我try 下载时:
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;
插入
这就是文件的实际内容...
它显然能找到文件.但为什么不下载呢?