Laravel 5 - How to access image uploaded in storage within View?

前端 未结 12 2649
悲哀的现实
悲哀的现实 2020-11-22 14:05

I have got user\'s avatars uploaded in Laravel storage. How can I access them and render them in a view?

The server is pointing all requests to /public,

12条回答
  •  攒了一身酷
    2020-11-22 14:15

    According to Laravel 5.2 docs, your publicly accessible files should be put in directory

    storage/app/public
    

    To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public.

    ln -s /path/to/laravel/storage/app/public /path/to/laravel/public/storage
    

    Now you can create in your view an URL to the files using the asset helper:

    echo asset('storage/file.txt');
    

提交回复
热议问题