MongoGridFSFile::getResource

(PECL mongo >=1.3.0)

MongoGridFSFile::getResourceReturns a resource that can be used to read the stored file

说明

public MongoGridFSFile::getResource ( void ) : resource

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($stream8192);
}
?>
相关文章
php deque returns a representation that can be converted to jsonphp pair returns a representation that can be converted to jsonphp priorityqueue returns a representation that can be converted to jsonphp stack returns a representation that can be converted to jsonphp vector returns a representation that can be converted to jsonphp mcve 函数 returns array of strings which represents the keys that can be used for response parameters on this transactionphp svn 函数 creates and returns a stream that will be used to replacephp mongodb bson binary returns a representation that can be converted to jsonphp mongodb bson dbpointer returns a representation that can be converted to jsonphp mongodb bson int64 returns a representation that can be converted to jsonphp mongodb bson javascript returns a representation that can be converted to jsonphp mongodb bson maxkey returns a representation that can be converted to jsonphp mongodb bson minkey returns a representation that can be converted to jsonphp mongodb bson objectid returns a representation that can be converted to jsonphp mongodb bson regex returns a representation that can be converted to jsonphp mongodb bson timestamp returns a representation that can be converted to jsonphp mongodb bson undefined returns a representation that can be converted to jsonphp mongodb bson utcdatetime returns a representation that can be converted to jsonphp mongogridfsfile returns a resource that can be used to read the stored filephp swoole mmap map a file into memory and return the stream resource which can be used by php stream operations.
关注编程学问公众号