|All requests||>||Using PHP 7 Insert image in the MySQL...||>||Request new recommendation||>||Featured requests||>||No recommendations|
by Vicente Paulo Maciel - 3 years ago (2015-12-26)
I want to use PHP 7 and insert an image in a MySQL database, as well and display image in the browser.
3. by Arash. Ataei - 3 years ago (2016-01-20) Reply
you can use blob data entry in mysql, and after that, using connection claass with an INSERT (<code>insert into ?table.?db () values() </code>).
2. by Arash. Ataei - 3 years ago (2016-01-20) Reply
1. by Manuel Lemos - 3 years ago (2016-01-19) Reply
There are several classes for inserting images in databases but they use the old MySQL extension.
What you may do is to use one of those classes and then use Dave Smith MySQL to MySQLi wrapper class, so mysql calls are mapped to mysqli calls.
take a look at my Image Embedder class, it might be what you're looking for; I designed it to embed images into html using base64 encoding. Take a look at the 'img_fixer.php' code near the 'base64_encode_image ' function and you'll get an idea of how you could solve this problem for storing your image data in a normal text field.
Now depending on how you want to retrieve, you can always send the header for your images MIME type and print the decoded Base64 data that you queried, then exit the script for that image; or you can embed it into your document with something like <img src="data:Image/[gif, jpg or png];base64,[base64_encodeed image string]" /> for each image -- this is most ideal for smaller images though.