如何使用* BLOB在Laravel 5.3中显示图像?

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:

DB::table('movies')->insert([
  'image' => file_get_contents( "public/images/image.jpg" )
]);

(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:

$blob = ''; //from database
echo '<img src="data:image/jpeg;base64,'.base64_encode( $blob ).'"/>';

This is converting the data to a DATAURI, which you can read about here as a quick-to-read article.

Hope this helps!