开发者

how to display an image from a mysql blob field in symfony?

开发者 https://www.devze.com 2023-01-25 04:02 出处:网络
How do I display an image from a mysql blob field in symfony? Now it\'s only echo the text \'Array\'.

How do I display an image from a mysql blob field in symfony? Now it's only echo the text 'Array'.

Is it possible just to add a new property to the indexSuccess.php like

<开发者_如何学编程img src="<?php echo $persons->getPhoto('[property]') ?>" />

or

<img src="<?php echo $persons->getPhoto()->[property] ?>" />

to print it correctly?


The src attribute contains a location, not the image data itself - with the exception of data URIs.

You need to create another page that sets the correct headers and outputs the image data from the DB, and point to that in your src.

The alternative is to echo a data URI in the src attribute.

Also keep in mind that if you have output escaping on, symfony also escapes the data in your blob field while being passed to the view layer.

0

精彩评论

暂无评论...
验证码 换一张
取 消