jeudi 5 avril 2018

Laravel deploy: storage image doesn't work correctly

After deploying my laravel project from local to Apache web server, all works correctly except images link. Here the code:

Images are stored in:

storage/app/public/photos

after i've run command:

php artisan storage:link

Images are linked at:

public/storage/photos

Controller:

if ($request->hasFile('photo')) {
   $extension = $request->file('photo')->getClientOriginalExtension();
   $file = $request->file('photo');
   $photo = $file->storeAs('public/photos', 'foto-' . time() . '.' . $extension);
   $user->photo = $photo;
   $user->save();
}

Images are uploaded correctly on storage/app/public/photos and correctly linked in public/storage/photos but it doesn't display on frontend.

in blade, i've tried to use Storage::url to retrieve the path



and asset()



in both cases, image doesn't exist

The public path of image is:

http://mywebsite.com/storage/photos/foto-1522914164.png



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire