PHP - Attach HTML to Image/Jpeg Response -


the code below:

if($file = $mongogridfs->findone(array('_id' => new mongoid($fileid))))  {     $filename = $file->file['filename'];     $filebytes = $file->getbytes();     header('content-type: image/jpeg');     header("content-length: " . strlen($filebytes));     ob_clean();     echo $filebytes; } 

returns response mongo .jpg file.

how include response html? eg.

<div id='container'>   <img ... /> <!-- image generated script , stored in $filebytes -->   <br>   <span class='description'>this image</span> </div> 

i want not make <img src='...'> linked saved file on filesystem.

is possible?

you cannot return 2 resources within same http response. can inline image data (see embedding base64 images more details browser compatibility , other possible issues inline images). like:

<img src="data:image/jpeg;base64,<?=base64_encode($filebytes)?>" /> 

Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -