I want to save my avatar in the "Public" folder and get it.
OK. I can save it, but in the folder "storage / app" instead of "public"
my friend told me to go to "config / filesystem.php" and edit it, so I did it like this
'disks' => [
'public' => [
'driver' => 'local',
'root' => storage_path('image'),
'url' => env('APP_URL').'/public',
'visibility' => 'public',
],
still no change.
here are my simple codes
Route:
Route::get('pic',function (){
return view('pic.pic');
});
Route::post('saved','test2Controller@save');
controller
public function save(Request $request)
{
$file = $request->file('image');
$format = $request->image->extension();
$patch = $request->image->store('images');
$name = $file->getClientOriginalName();
DB::table('pictbl')->insert([
'orginal_name'=>$name,
'format'=>$base,
'patch'=>$patch
]);
return response()
->view('pic.pic',compact("patch"));
}
View:
{!! Form::open(['url'=>'saved','method'=>'post','files'=>true]) !!}
{!! Form::file('image') !!}
{!! Form::submit('save') !!}
{!! Form::close() !!}
<img src="storage/app/{{$patch}}">
How to save my image (and file in the future) in a shared folder instead of storage?
source
share