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

后端 未结 5 955
悲&欢浪女
悲&欢浪女 2021-01-06 05:49

I have no idea on how to create symbolic link or symlink.

I am working on File system in laravel 5.2.

The document says th

相关标签:
5条回答
  • 2021-01-06 06:27

    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]);
       }
    

    0 讨论(0)
  • 2021-01-06 06:32

    Run this command:

    php artisan storage:link
    
    0 讨论(0)
  • 2021-01-06 06:44
    App::make('files')->link(storage_path('app/public'), public_path('storage'));
    

    And don't forget to use App after namespace.

    0 讨论(0)
  • 2021-01-06 06:46

    In a Windows environment, you can:

    1. cmd with Run as administrator
    2. Run the mklink command:
    mklink /D "C:\xampp\htdocs\xxxx\yyy\public\storage\" 
    "C:\xampp\htdocs\xxxx\xxx\storage\public\"
    
    0 讨论(0)
  • 2021-01-06 06:50

    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');
    }
    
    0 讨论(0)
提交回复
热议问题