In This Tutorial We’ll create an application for uploading photographs and videos with user authentication utilizing MongoDB and Mongoose; then we will see the pictures that are going to be the top results of our work.

Preview of our App

Inserting images in the application using the upload form

Inserting video files into the application using the upload form

Lets start with the package.json file. The packages.json is main file  of the application.

  1. Create a folder called dunebookapp
  2. Create a new file called package.json and save it in the dunebookapp folder with the following code:
            "name": "dunebookapp", 
            "description": "multimedia App with Node.js", 
            "license": "MIT", 
            "author": { 
              "name": "dunebook Tutorial", 
              "url": "" 
            "repository": { 
              "type": "git", 
              "url": "" 
            "keywords": [ 
              "Express Application", 
              "Expressjs images upload", 
              "Expressjs video upload" 
            "version": "0.0.1", 
            "private": true, 
            "scripts": { 
              "start": "node app.js" 
             "dependencies": { 
              "bcrypt-nodejs": "0.0.3", 
              "body-parser": "~1.13.2", 
              "connect-flash": "^0.1.1", 
              "connect-mongo": "^1.1.0", 
              "cookie-parser": "~1.3.5", 
              "debug": "~2.2.0", 
              "ejs": "~2.3.3", 
               "express": "~4.13.1", 
              "express-session": "^1.13.0", 
              "gravatar": "^1.4.0", 
              "mongoose": "^4.4.5", 
              "morgan": "~1.6.1", 
              "multer": "^1.1.0", 
              "node-sass-middleware": "0.8.0", 
              "passport": "^0.3.2", 
              "passport-local": "^1.0.0", 
              "serve-favicon": "~2.3.0" 
            "devDependencies": { 
              "nodemon": "^1.9.1" 


Now let’s Add some of useful files to our project:

  1. Create a file called .editorconfig and save it in the dunebookapp folder with the following code:
          root = true 
          indent_style = tab 
          indent_size = 4 
          charset = utf-8 
          trim_trailing_whitespace = true 
          insert_final_newline = true 
          trim_trailing_whitespace = false 
  2. Create a file called .gitignore, save it in dunebookapp , and include the following code:
          # Logs 
          # Runtime data 
          # Directory for instrumented libs generated by jscoverage/JSCover 
          # Coverage directory used by tools like newyork 
          # Grunt intermediate 
          storage ( 
          # node-waf configuration 
          # Compiled binary addons ( 
          # Dependency directory 
          # Debug log from npm 
  3. Create a file called app.js.

Add essential server folders

We will now create the directories that store controls, the templates, and other files of the application:

  1. Create a folder called public, and inside of it, create the following folders:
    • /images
    • /javascripts
    • /stylesheets
    • /uploads
    • / videos
  2. Create a folder called server, and inside of it, create these folders:
    • /config
    • /controllers
    • /models
    • /views
  3. At this time, our project has all the basic directories and files; let’s install the Node modules from package.json.
  4. Open your terminal/shell at the root project folder and type the following command:
    npm install

    Let’s starting creating the app.js file content.