Reputation: 1146
i have the blade in this route:
/resources/views/cms/public/views/projects/showproject.blade.php
And the code to render the picture is this:
@if (Storage::disk('projects')->has($project->slug))
<p class="lead"><img src="{{ asset('/storage/projects/'.$project->slug.'/home.png') }}" width="50%" >Home</p>
@else
<p class="lead"><img src="/assets/img/projects/{{$project->slug}}/home.png" width="50%">Home</p>
@endif
The storage disk called projects looks like here:
'projects' => [
'driver' => 'local',
'root' => storage_path('app/public/projects'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
The error is this:
header.png Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I think the problem is in the code on the view, i also read maybe i need use a symbolic link, isn't possible make it without?
Any help will be appreciated, if have any question ask it please.
Thanks. (I check the others question of stackoverflow before, and can't find the error).
Upvotes: 1
Views: 8041
Reputation: 457
From the Documentation https://laravel.com/docs/5.4/filesystem:
The Public Disk
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. This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.
To create the symbolic link, you may use the storage:link Artisan command:
php artisan storage:link
Of course, 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');
Upvotes: 2