Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.4 Storage link

i would like to show a picture in html file i go to the link folder public/storage/image is empty but in the storage/image i find the file and its also saved in the data base.*

@foreach($cvs as $cv)
                    <div class="col-sm-6 col-md-4">
                    <div class="thumbnail">
                        <img src="{{ asset('storage/'.$cv->photo) }}" alt="...">
                        <div class="caption">
                        <h3>{{ $cv->titre }}</h3>
                        <p>{{$cv->presentation}}</p>
                        <p>
                            <a href="#" class="btn btn-primary" role="button">Afficher</a>
                            <a href="#" class="btn btn-success" role="button">Modifier</a>
                            <a href="#" class="btn btn-danger" role="button">Supprimer</a>
                         </p>
                        </div>
                    </div>
                    </div>
                    @endforeach
                    </div>
               </div>
like image 402
mouhamed slaimi Avatar asked May 05 '18 02:05

mouhamed slaimi


People also ask

How do I run a storage link in Laravel?

use Illuminate\Support\Facades\Storage; $url = Storage::url('file.jpg'); When using the local driver, all files that should be publicly accessible should be placed in the storage/app/public directory. Furthermore, you should create a symbolic link at public/storage which points to the storage/app/public directory.

What is the use of php artisan storage Link?

What is php artisan storage link? php artisan storage:link. Once a file has been stored and the symbolic link has been created, you can create a URL to the files using the asset helper: echo asset('storage/file. txt'); You may configure additional symbolic links in your filesystems configuration file.

How can I get Laravel storage file?

How can I get Laravel storage file? Laravel's filesystem configuration file is located at config/filesystems. php . Within this file, you may configure all of your filesystem "disks".


2 Answers

First of all in the .env file create a variable named FILESYSTEM_DRIVER and set it to public like this

FILESYSTEM_DRIVER=public

and then create symbolic link by run

php artisan storage:link

after that just use asset()

<img src="{{ asset('storage/'.$cv->photo) }}" alt="...">

It'll work fine 😊

like image 180
Aamir Kalimi Avatar answered Oct 05 '22 23:10

Aamir Kalimi


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. Laravel doc

Create Symbolic link in Linux

ln -s source_file myfile
like image 20
Mayank Majithya Avatar answered Oct 06 '22 00:10

Mayank Majithya