Home > other >  My uploaded image doesn't save in the storage file
My uploaded image doesn't save in the storage file

Time:10-11

I've followed the steps of Laracasts, but it's not working.

When I submit the form it returns:

Done: storage/thumbnails/k0TF3NW6WvWWjHuEtZ0OW7TTRQbfSB6lvD1GJls3.png

But I couldn't find it anywhere. My storage/thumbnails is empty.

My Controller:

  $path = request()->file('thumbnail')->store('storage/thumbnails');
  return 'Done: ' . $path;

My filesystems.php

'default' => env('FILESYSTEM_DRIVER', 'public'),


        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

How can I find the uploaded file? Thanks!

CodePudding user response:

Could you try this code please.

$file = $request->file('thumbnail');
$file_name = uniqid()."_".time().'.'.$file->extension();
$file_location = '/thumbnail/';
$file-> move(storage_path($file_location), $file_name);

I hope the code helps you. Have a good one :)

CodePudding user response:

Have you tried "php artisan storage:link" command?

  • Related