This example shows how to list the files in a grid collection.
<?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
$cursor = mongo_gridfs_list($gridfs, array("filename" => "profilePic.jpg"));
while (mongo_has_next($cursor)) {
$f = mongo_next($cursor);
echo $f["filename"] . "\n";
}
?>
Результатом выполнения данного примера
будет что-то подобное:
file1.txt
file2.txt
mypic.jpg
depending on what is in the database.