Preston Garvey
Preston Garvey

Reputation: 1421

How to display images from storage path?

How to display images from storage folder (outside public) ? I stored my image files in storage/cover but unable to display it to view. My show method :

public function index() {
        $categories = Category::with('post')->orderBy('id', 'desc')->paginate(4);
        return view('dashboard/categories/index', compact('categories', $categories));
    }

The view :

<?php foreach ($categories as $cat): ?>
            <div class="col-xs-6 col-sm-4 col-md-3">
                <div class="blog-item">
                    <a href="{{ url('dashboard/categories/' . $cat->titleslug) }}" class="blog-img"><img src="{{asset('cover/'. $cat->cover)}}" class="img-responsive" alt=""/></a>
                </div><!-- blog-item -->
            </div><!-- col-xs-6 -->
        <?php endforeach; ?>

That's all and thanks!

Upvotes: 1

Views: 3239

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163978

The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public

https://laravel.com/docs/5.4/filesystem#configuration

Then you'll be able to do something like this:

<img src="{{ asset('storage/cover/'.$cat->cover) }}" ....

Upvotes: 5

Related Questions