im trying to upload files to mongo from php7.1
Hi Naren,
You can use MongoDB PHP Library to upload files into GridFS. Make sure you follow the installation steps, afterwards you can try out below code:
<?php
require 'vendor/autoload.php';
$client = new MongoDB\Client("mongodb://user:pwd@host:port");
$bucket = ($client)->databaseName->selectGridFSBucket();
$file = fopen('/path/to/example.png', 'rb');
$bucket->uploadFromStream('example.png', $file);
?>
For more examples see MongoDB PHP Library GridFS Tutorial).
See also the manual for Composer Autoloading.
Regards,
Wan.