我想将我的头像保存在“公共”文件夹中然后检索。
好的。我可以保存它,但在“storage/app”文件夹而不是“public”
我的朋友告诉我去“config/filesystem.php”并编辑它,所以我这样做了
'disks' => [
'public' => [
'driver' => 'local',
'root' => storage_path('image'),
'url' => env('APP_URL').'/public',
'visibility' => 'public',
],
仍然没有变化。
这是我的简单代码
路线 :
Route::get('pic',function (){
return view('pic.pic');
});
Route::post('saved','test2Controller@save');
控制器
public function save(Request $request)
{
$file = $request->file('image');
//save format
$format = $request->image->extension();
//save full adress of image
$patch = $request->image->store('images');
$name = $file->getClientOriginalName();
//save on table
DB::table('pictbl')->insert([
'orginal_name'=>$name,
'format'=>$base,
'patch'=>$patch
]);
return response()
->view('pic.pic',compact("patch"));
}
看法:
{!! Form::open(['url'=>'saved','method'=>'post','files'=>true]) !!}
{!! Form::file('image') !!}
{!! Form::submit('save') !!}
{!! Form::close() !!}
<img src="storage/app/{{$patch}}">
如何将我的图像(和将来的文件)保存在公共文件夹而不是存储中?
原文由 Siros Fakhri 发布,翻译遵循 CC BY-SA 4.0 许可协议
在 config/filesystems.php 中,您可以这样做…更改公共的根元素
你可以通过