//gridfs has three ways to store files
//The first method is to store files directly
$id = $grid->storeFile("./logo.png");
//The second storage file binary stream
$data = get_file_contents("./logo.png");
$id = $grid->storeBytes($data,array("parame" =>'Additional parameters will be stored with the image'));
//The third way to save files submitted by direct forms $_FILES
$id = $grid->storeUpload('upfile');
//Equivalent to
$id = $grid- >storeFile($_FILES['upfile']['tmp_name']);
//-------------The above is the saved image--below to start reading the image-------------
//Return $id = md5 string after successful saving
$logo = $grid->findOne(array('_id'=>$id)); //Get the file using _id as the index
header('Content-type: image/png'); //Output image header
echo $logo ->getBytes(); //Output data stream
?>