Category Archives: PHP Programming

What is Accessor in Laravel?

As we know laravel accessor is very userful feature. It is used for creating the virtual attribute on the object which you want to access it as database column name. So for example if you want to show full name and in your database table (users) has first_name and last_name columns, you can write: Then you can call $user->full_name and it… Read More »

How to display image from database in PHP?

Step1 : Fetch/Retrieve the image from datbase using database functions. Step2 : Now use the image tag below. <?php $convertedImage =’CONVERTED_IMAGE_FROM_DB’; ?> <img src="data:image/jpg|gif|png;charset=utf8;base64,$convertedImage" /> jpg/gif/png depends on the type of image.<?php $convertedImage =’CONVERTED_IMAGE_FROM_DB’; ?> <img src="data:image/jpg|gif|png;charset=utf8;base64,$convertedImage" /> jpg/gif/png depends on the type of image.

How to save image in Database using PHP ?

Step 1: First of all Convert image to binary.   <?php $imageURL =’YOUR_IMAGE_URL’; //or you can upload $convertedImage = base64_encode(file_get_contents($imageURL)); /** Now store $convertedImage in Database using database functions.**/   ?> <?php $imageURL =’YOUR_IMAGE_URL’; //or you can upload $convertedImage = base64_encode(file_get_contents($imageURL)); /** Now store $convertedImage in Database using database functions.**/ ?>