php - Laravel storage link won't work on production - Stack Overflow

PHOTO EMBED

Tue May 24 2022 20:34:10 GMT+0000 (Coordinated Universal Time)

Saved by @oday #php

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

if ($request->hasFile('image')) {
  $image = $request->file('image');
  $filename = 'page' . '-' . time() . '.' . $image->getClientOriginalExtension();
  $location = public_path('app/public_html/images/' . $filename);
  Image::make($image)->resize(1200, 600)->save($location);
  if(!empty($page->image)){
    Storage::delete('images/' . $page->image);
  }
  $page->image = $filename;            
}






What I did to solve this problem:

1.go inside the project folder using ssh
2.if public folder not exist, create it. If already created, then make sure the storage symlink you created in development been deleted.
3.do php artisan storage:link
4.move the storage symlink that created to the public_html folder
5.done.
content_copyCOPY

https://stackoverflow.com/questions/50730143/laravel-storage-link-wont-work-on-production