samedi 21 avril 2018

Saving uploaded image file in public dir not working in laravel 5.6

I have created a designated location to store all the uploaded images in public dir like this:

enter image description here

and I have the default config/filesystem.php for public driver like this:

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

Within my repository, I am trying to save the uploaded image like this:

    // ... snipped        

    if (array_key_exists('logo', $validated)) {
        $logoPath = $validated['logo']->store(
            'uploads/logos',
            'public'
        );
        $company->logo = url($logoPath);
    }

    $company->save();

In the database, I can see the value of logo field for the company record like this: http://my-app.local/uploads/logos/3hlsAhnnIPjd4zhdpfhvKw4tqDkpcCz23NczwhVM.png

However, the public/uploads/logos dir is empty. Any idea what might be wrong here? Am I supposed to use the ->move() method on the UploadedFile instead of ->store()?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HS3MHs
via IFTTT

Aucun commentaire:

Enregistrer un commentaire