Sorry, I am new coding html and php and at this point I don´t know how to progress. What I want to do is the next:
I am using a xampp server where I have a folder with images already stored on the server like this:
/img/ima1.png
/img/ima2.png
/img/ima3.png
I want to use PHP to save this images on a MySQL database as a blob without using html form, just use the path of the image to get the content and save it on my database, without a tmp file and forms.
please is this possible?
Thanks in advance!
mysql LOAD_FILE
reference
INSERT INTO `table_name` (`column_name`)
VALUES(LOAD_FILE('/full/path/to/new/image.jpg'));
$sql = "INSERT INTO ImageDb(Image)
VALUES("file_get_contents('/img/ima2.png')")";
try the above sql statement
You can insert all image path from a folder using simple php script. Suppose folder name “images” . Use glob for this. This is php code
$dirname = "media/images/";
$images = glob($dirname."*.png");
foreach($path as $images) {
INSERT INTO `table_name` (`column_name`)
VALUES(('$path'));
}