©
Ce document utilise Manuel du site Web PHP chinois Libérer
(PECL mongo >=1.3.0)
MongoGridFSFile::getResource — Returns a resource that can be used to read the stored file
This method returns a stream resource that can be used with all file functions in PHP that deal with reading files. The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first.
At most two GridFSFile chunks will be loaded in memory.
此函数没有参数。
Returns a resource that can be used to read the file with
Example #1 MongoGridFSFile::getResource() example
<?php
$m = new Mongo ;
$images = $m -> my_db -> getGridFS ( 'images' );
$image = $images -> findOne ( 'mongo.png' );
header ( 'Content-type: image/png;' );
$stream = $image -> getResource ();
while (! feof ( $stream )) {
echo fread ( $stream , 8192 );
}
?>
[#1] chuck at manchuck dot com [2013-02-15 12:28:54]
Please note that the file pointer is reset on each call to get resource