(PECL mongo >= 0.8.0)
mongo_gridfile_write — Write a file from the database to the local filesystem
Write a file from the database to the local filesystem.
The grid file.
Name to save the file under.
Returns the number of bytes written.
Beispiel #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");
?>