Save image to shared folder instead of laravel 5 storage

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');
        //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"));
}

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?

+4
source share
2 answers

In config / filesystems.php you can do this ... change the root element in the public

'disks' => [
   'public' => [
       'driver' => 'local',
       'root'   => public_path() . '/uploads',
       'url' => env('APP_URL').'/public',
       'visibility' => 'public',
    ]
]

and you can access it

Storage::disk('public')->put('filename', $file_content);
+8

php artisan storage:link

, , :

{{ asset('storage/file.txt') }}

:

<img src="{{ asset('storage/app/' . $patch) }}">
+1

Source: https://habr.com/ru/post/1671280/


All Articles