Skip to content
Advertisement

Laravel storage link won’t work on production

I’m using storage_path to save my images and I symbolic my storage folder to public_html

php artisan storage:link

On the local everything works fine, when I upload an image it will upload in storage folder and link of it will appear in public folder but since I moved to live host and production mode my images will upload in storage folder but nothing in my public_html/storage and I’m not able to get them in my front-end.

Codes

/config/filesystems.php

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

.env

FILESYSTEM_DRIVER=public

controller sample

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

any idea?

Advertisement

Answer

SOLVED

Thanks for all your helps, I tried to run php artisan storage:link on my server and I found out that my server has disabled symlink for security reason.

So I have changed all my image uploading functions to upload images in my public folder instead of storage folder and now everything is working just fine.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement