Image/File Uploading Downloading

How to upload, fetch & downaload image/file in php mongodb (like in php mysql)?

  • Vasant
  • 29 Jun 2018
  • 371 Views
  • 2 Answers
Your Answer

For Uploading image you can take an example that simplifies the code :
<form method="POST" action="" enctype="multipart/form-data">
................... <input type="file" name="cover" >
.................. <button type="submit">Submit</button> </form>

now, for fetching image from database, see the code below :

// Establish MongoDB Connection $connection = new MongoDB\Client("mongodb://localhost:27017"); $databaseMongo = $connection->selectDatabase(Config::get('DB_NAME'));
$questions = $databaseMongo->selectCollection("questions");
$questionsArray = $questions->find()->toArray();
foreach ($questionsArray as $question) { if ($level == 1) { $myQuestion = $question; break; }
}
hope above information would help to upload and fetch file in mongodb
 

Mongodb

Didn't get the answer.
Contact people of Talent-Mongodb directly by clicking here