Option 1: Add image upload to your website and save image’s url to database.
Option 2: Use base64_encode()
for converting image to text.
$image = file_get_contents($_FILES['your_fileupload_name']['tmp_name']);
$ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
$base64 = 'data:image/' . $ext . ';base64,' . base64_encode($image);
Then you save $base64
to your database, and you can convert it to image using base64_decode()
when you are reading the database.
I prefer Option 1, because it’s more efficent. Base64 encoding increases image size by 33%.
1
solved How to save a message with an image in a database [closed]