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

tcpdump - How to check if server received packet (acknowledged) -