简体   繁体   中英

Issue while fetching file from storage path in Blade: Laravel 5.2

I am trying to set the file path which is present in below folder.

storage/Asset/Media/1/FileName

For that, I wrote below code.

<img class="img-responsive avatar-view" 
src={!! 
        URL("/storage/Asset/Media/1/FileName.png)  
    !!}
>

This produces below path

http://localhost/AdminSystem/public/storage/Asset/Media/1/filename.png

and my file is in below path

http://localhost/AdminSystem/storage/Asset/Media/1/filename.png

Please suggest if I missed anything to get file from storage path

you can follow this method,

storage_path().'/Asset/Media/1/FileName.png'

means

<img class="img-responsive avatar-view" src="{!!storage_path().'/Asset/Media/1/FileName.png'!!}">

Try this:

The best way to fetch any file from storage is you first define the root of this file and use it every time.

For example in Route.php you can define it in following way.

define('MEDIA_ROOT', '/storage/Asset/Media');

Whenever you want to show it there use this code:

 <img src="{{ MEDIA_ROOT.'/1/FileName.png' }}"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM