我正在编写一些代码来在网页上显示图像。下一个代码显示网络中的数据,但不显示图像。我可以更改什么来显示网络中的图像。
<?php
$m = new MongoClient();
$db = $m->selectDB("local");
// Get the users collection
//$c_faq = $db->faq;
// GridFS
$grid = $db->getGridFS();
// The file's location in the File System
$path = "C:\Wamp\Apache\htdocs\knowledge\scripts";
$filename = "\imagen1.png";
// Note metadata field & filename field
$storedfile = $grid->storeFile($path . $filename,
array("metadata" => array("filename" => $filename),
"filename" => $filename));
// Return newly stored file's Document ID
echo $storedfile;
// GridFS
$gridFS = $db->getGridFS();
// Find image to stream
$image = $gridFS->findOne("\imagen1.png");
// Stream image to browser
header('Content-type: imagen.png');
echo $image->getBytes();
?>