Home > Net >  Images I upload in Laravel don't show after I have tried many answers online. All the images I
Images I upload in Laravel don't show after I have tried many answers online. All the images I

Time:09-28

I have this in view. It is able to upload alright but it won't show. Is there anything more I should add?

 <div class="col-md-4">
 <img class="img img-fluid img-thumbnail" src="/storage/profile_images/{{$profile->profile_image}}"/> </div>

here is my show.blade.php file

<div class="col-md-4">
<img class="img img-fluid img-thumbnail" src="/storage/profile_images/{{$profile->profile_image}}"/></div>

Here is the player.blade.php file:

@if(count($players) > 0)
    <?php $index = 0; ?>
    @foreach($players as $player)
        <div class="col-md-4">
            <div class="card mb-1" style="width:300px">
                <div class="card-body">
                    <img class="img img-fluid img-thumbnail" style="height: 170px; width: 350px" src="/storage/profile_images/{{$player->profile_image}}">
                </div>
                <div class="card-footer">
                    <div class="row justify-content-center">
                        <a href="/playerprofiles/{{$player->id}}" class="h5">{{$names[$index]}}</a><br>
                    </div>
                    <div class="row">
                        <div class="col-10">
                            <span class="h6">Team: {{$player->current_fc}}</span><br>
                            <span class="h6">Position: {{$player->position}}</span><br>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php $index  ; ?>
    @endforeach
    <div class="col-12 mt-3">
        {{$players->appends(request()->input())->links()}}
    </div>
@else
    <p>No Players available</p>
@endif
                    

CodePudding user response:

Please use asset Try Like Blow Code

 @php
    $imgUrl = '/storage/profile_images/'.$profile->profile_image;
 @endphp
<img class="img img-fluid img-thumbnail" src="{{ asset($imgUrl)}}"/>

Also check if storage link or not

php artisan storage:link

CodePudding user response:

Follow above your image issue will be resolved:

Step 1:

Delete storage folder from public

Step 2:

Inside your project run this command

player.blade.php

php artisan storage:link

Step 3:

Replace or change as per this:

show.blade.php

<div class="col-md-4">
<img class="img img-fluid img-thumbnail" src="{{ url('storage/profile_images/.$profile->profile_image) }}" /></div>

Step 4:

Replace or change as per you required:

@if(count($players) > 0)
    <?php $index = 0; ?>
    @foreach($players as $player)
        <div class="col-md-4">
            <div class="card mb-1" style="width:300px">
                <div class="card-body">
                    <img class="img img-fluid img-thumbnail" style="height: 170px; width: 350px" src="{{ url('storage/profile_images/.$profile->profile_image) }}">
                </div>
                <div class="card-footer">
                    <div class="row justify-content-center">
                        <a href="/playerprofiles/{{$player->id}}" class="h5">{{$names[$index]}}</a><br>
                    </div>
                    <div class="row">
                        <div class="col-10">
                            <span class="h6">Team: {{$player->current_fc}}</span><br>
                            <span class="h6">Position: {{$player->position}}</span><br>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php $index  ; ?>
    @endforeach
    <div class="col-12 mt-3">
        {{$players->appends(request()->input())->links()}}
    </div>
@else
    <p>No Players available</p>
@endif
  • Related