To start, I'd like to know how to send an image from my public folder, I have a column image
of type MEDIUMBLOB
in my table named movies. I'm using mysql_*
as my database connection.
This is my current seed:
public function(){
DB::table('movies')->insert([
'name' => 'La vida es bella',
'score' => '0',
'date' => '1999-2-26',
'image' => ??????????
]);
}
If you're trying to input image data to your
MySQL
table, use the following structure of code:(I don't use
Laravel
, or the connection type you're using, that's just the way you insert*BLOB
data into a database.The main function to take away from this is
file_get_contents( IMAGE_LOCATION )
, which will get the raw image data and uses that as the blob, and if you wanted to pull it from the database you'd just have to pack it into the correct mime, like so:This is converting the data to a
DATAURI
, which you can read about here as a quick-to-read article.Hope this helps!