php7.1存储文件并从mongdb 1.2.8中检索文件

Need help in dealing with files in php7.1 mongodb(1.2.8)

we are able to insert and fetch normal records(like id, name) in php7.1 mongodb1.28. need to know how we can store files and retrieve files in mongodb with php7.1

// Connect to Mongo and set DB and Collection

$mongo = new Mongo();
$db = $mongo->myfiles;

// GridFS
$grid = $db->getGridFS();

// The file's location in the File System
$path = "/tmp/";

$filename = "filename.txt";

// Note metadata field & filename field
$storedfile = $grid->storeFile($path . $filename, array("metadata" => array("filename" => $filename),"filename" => $filename));

// Return newly stored file's Document ID
echo $storedfile;

looking similar in php7.1

appreciates your help

thanks Naren