How to create symlink from public/storage to storage/app/public in laravel?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 01:02:33
App::make('files')->link(storage_path('app/public'), public_path('storage'));

And don't forget to use App after namespace.

On Shared Server, where one doesn't have ssh access to run php artisan storage:link this helps me run that from a controller, the if block code section can also be placed in a Service Provider as well as suggested by @shìpu-ahamed

public function displayForm()
{

        if(!file_exists(public_path('storage'))) {
           \App::make('files')->link(storage_path('app/public'), public_path('storage'));
    }
        return view('admin.index');
}
joy

Added same code but still getting issue. Method link does not exist. currently i am adding link in my controller constructor.

here is code:

       public function index()
  {
     $shots=[];
      App::make('files')->link(storage_path('app\public'), public_path('..\public\storage'));
     return View::make('adminpages.index',['shots'=>$shots]);
   }

Run this command:

php artisan storage:link
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!