When I upload BLOB images through an HTML form, even though they are stored in the database, the images are not displayed on the corresponding table. When I upload the BLOB images through phpMyAdmin, they are displayed properly. It looks like when uploading through the form, the BLOB images are significantly smaller than the ones being uploaded via phpMyAdmin. I am using Laravel routes and views.

Here is a screenshot of the phpMyAdmin table. The first two BLOBs (212.1 KiB and 214.6 KiB) were uploaded via phpMyAdmin, and the last two (11 B and 10 B) were uploaded through the HTML form.

phpMyAdmin BLOB comparisons

Here is my submission form in submit.blade.php:

<form action="/submit" method="post" enctype="multipart/form-data">

    {!! csrf_field() !!}

    <div class="form-group{{ $errors->has('image') ? ' has-error' : '' }}">
        <label for="image">Image</label>
        <input type="file" class="form-control" id="image" name="image" placeholder="Image" value="{{ old('image') }}">
        @if($errors->has('image'))
           <span class="help-block">{{ $errors->first('image') }}</span>
        @endif
    </div>

Here is how it is displayed in welcome.blade.php

@foreach ($event as $event)
  <table class='w100'> 
    <tr>
      <td class='w50' colspan=2 rowspan=6><img src= "data:image/png;base64,{{ chunk_split(base64_encode($event->image)) }}" height="100" width="100"/></td>
    </tr>
  </table>
@endforeach

I have a feeling it's an issue with how I'm getting the files in submit.blade.php, but I'm not sure how to properly go about fixing this.

0 Answers