I don't have the code sample handy just now, but it's very straightforward really. Upload the file to a temp location as you would normally do via a file submitting, then grab the file content and create a MongoBinData
object as below:
$record = array("name" => "my photo",
"photo" => new MongoBinData(file_get_contents("myself.jpg")));
$collection->insert($record);
This will then insert your image as binary into the DB. When retrieving it, just grab your record:
$record = $collection->findOne();
$imagebody = $record["photo"];
And echo
them out onto a php file as per below
header('Content-Type: image/jpeg');
// Output the image
imagejpeg($imagebody);