0
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;
}
返回從蒙戈如.jpg文件的迴應。
如何包含此回覆一些html?例如。
<div id='container'>
<img ... /> <!-- image generated by script and stored in $fileBytes -->
<br>
<span class='description'>This is image</span>
</div>
我不想讓<img src='...'>
鏈接到文件系統上的保存文件。
這可能嗎?
您是否想用jpg或html做出迴應?你不能擁有兩個。如果你想HTML,返回HTML並鏈接到該HTML中的問題圖像。 – 2015-04-01 12:53:33
我看到有人從字符串中提取圖像,然後他將這個圖像放到html中,但沒有鏈接。但我現在找不到這種方式。 – 123qwe 2015-04-01 12:56:27