Mongo Functions
PHP Manual

mongo_gridfile_write

(PECL mongo >= 0.8.0)

mongo_gridfile_writeWrite a file from the database to the local filesystem

Description

int mongo_gridfile_write ( resource $gridfile , string $filename )

Write a file from the database to the local filesystem.

Parameters

gridfile

The grid file.

filename

Name to save the file under.

Return Values

Returns the number of bytes written.

Examples

Example #1 mongo_gridfile_write() example

This example shows a file being retrieved from the database and saved to the local filesystem.

<?php

$conn 
mongo_connect("localhost"true);
if (!
$conn) {
   die(
"Could not connect.");
}
// create a new grid connection
$gridfs mongo_gridfs_init($conn"blog""fs");

// query for the filename
$file mongo_gridfs_find($gridfs, array("filename" => "profilePic.jpg"));
mongo_gridfile_write($file"pic.jpg");

?>


Mongo Functions
PHP Manual