Connect to GridFS using PHP and make Storing and retrieve images from GridFS

148 views
Skip to first unread message

srikanth B

unread,
Sep 21, 2017, 4:59:58 PM9/21/17
to mongodb-user
Hello,

I want to connect to MongoDB GridFS using PHP, the available methods are not supporting for the MongoDB 3.4 version.

I can not make connections to GridFS from PHP. I have searched so many links and documents in official website of MongoDB documentation. But it did not solve my issue.

Can any one Help me out.

Thanks.

Jeremy Mikola

unread,
Sep 22, 2017, 9:48:25 AM9/22/17
to mongod...@googlegroups.com
On Thu, Sep 21, 2017 at 9:26 AM, srikanth B <srikan...@gmail.com> wrote:
Hello,

I want to connect to MongoDB GridFS using PHP, the available methods are not supporting for the MongoDB 3.4 version.

I can not make connections to GridFS from PHP. I have searched so many links and documents in official website of MongoDB documentation. But it did not solve my issue.

It would be most helpful if you shared the PHP script you are attempting to run, a description of your MongoDB deployment, and the error(s) you're encountering.

The PHP library's The GridFS API is described in https://docs.mongodb.com/php-library/current/tutorial/gridfs/ and should certainly work with a 3.4 server. In fact, the GridFS specification should support all server versions, new and old alike. Note that if you're using the PHP library, you will also need the mongodb extension installed. The relationship between both packages is described in our architecture overview.
 

Can any one Help me out.

Thanks.

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/68c5b452-9840-4f07-9af2-a7b17e1e8fa7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

srikanth B

unread,
Sep 28, 2017, 1:31:38 AM9/28/17
to mongodb-user
Hello Jeremy,

This is the code which enables the connection with mongodb and access the database name 'test' and access the GridFS Bucket.

<?php
require 'vendor/autoload.php'; 
$client = new MongoDB\Client;
$db = $client->test;
$bucket = $db->selectGridFSBucket();

?>

 Fatal error: Call to undefined method MongoDB\Database::selectGridFSBucket() in C:\xampp\htdocs\BrainyTwist\bucket1.php on line 5

Jeremy Mikola

unread,
Sep 28, 2017, 10:30:43 AM9/28/17
to mongod...@googlegroups.com
The MongoDB\Database::selectGridFSBucket() method has existed since version 1.1.0 of the library. If the method is undefined, I suspect you may be using an older release of the library.

The steps outlined in Install the MongoDB PHP Library should ensure that Composer installs the most recent stable release (1.1.2 at the time of this writing).
 

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
Reply all
Reply to author
Forward
0 new messages