Created
May 23, 2012 12:00
Revisions
-
sharpred revised this gist
May 23, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,6 @@ //iterate through the collection and retrieve the named file $grid = $database->getGridFS(); foreach ($items as $item => $value) { $fileName =$value["metadata"]["uploaddata"]["filename"]; // md5 represents a unique key for a file so is a good one to use $md5 = $value["md5"]; -
sharpred created this gist
May 23, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <?php $mongoDB = new Mongo(); $database = $mongoDB->selectDB("BVS"); $collection = $database->createCollection('fs.files'); //to get the attachments metadata back $query = array("metadata.formdata.claimid" => "SUS14052012-001"); // $items is a cursor of mongodata $items = $collection->find($query); //iterate through the collection and retrieve the named file $grid = $database->getGridFS(); foreach ($items as $item => $value) { //echo "$item: "; $fileName =$value["metadata"]["uploaddata"]["filename"]; // md5 represents a unique key for a file so is a good one to use $md5 = $value["md5"]; $file = $grid->findOne(array("md5" => $md5)); $target = './' . $fileName; $file->write($target); }?>