Image/File Uploading Downloading

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


2 Answers
1-2 of  2
2 Answers
  • 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
     

  • In Ruby on Rails, use paperclip and carrierwave gems

Mongodb

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