显示通过mongodb gridFS提供的图像是否有限制?

时间:2013-04-29 21:33:59

标签: php mongodb

我只是测试mongodb gridFS处理图像请求的能力。该片段从gridFS获取图像并将其显示在网页上。这里的问题是,当我从25增加限制时,不显示图像。是否有对gridF的服务限制或我的测试方法是错误的?

$gridFS = $db->getGridFS();
$objects = $gridFS->find()->limit(25);

while($object = $objects->getNext()){

    echo " <img src=\"".$_SERVER['PHP_SELF']."?id=".$object->file['id']."\"> ";

}

if(isset($id) AND $id!=""){ 
    $gridFSa = $db->getGridFS();
    $object = $gridFSa->findOne(array('id'=>new MongoId($id)) );
    header("Content-Length: " . strlen($object)); 
    header("Content-Type: image/jpeg"); 
    ob_clean(); 
    echo $object->getBytes();
}

0 个答案:

没有答案