How to store image in base64 encode to database in laravel

  Kiến thức lập trình

Base64 encoded image is stored in table but when i m trying to display its not showing in edit page.

   $base64Image = null;
   if ($request->hasFile('profile_picture')) {
     $image = $request->file('profile_picture');
     $base64Image = base64_encode(file_get_contents($image));
   }

   $teacher->profile_picture = $base64Image;```


 <div class="form-group">
   <label>Upload Profile Picture</label>
   <input type="file" class="dropify" name="profile_picture" id="dropify-event" data-default-file="data:image/jpeg;base64,{{ $teacher->profile_image }}">
  <img src="data:image/png;base64,{{ base64_encode($teacher->profile_image) }}" alt="Profile Picture">
</div>

LEAVE A COMMENT