text: const express = require('express');
  const multer = require('multer');
  const ejs = require('ejs');
  const path = require('path');
  
  // Set The Storage Engine
  const storage = multer.diskStorage({
    destination: './public/uploads/',
    filename: function(req, file, cb){
      cb(null,file.fieldname + '-' + Date.now() + path.extname(file.originalname));
    }
  });
  
  // Init Upload
  const upload = multer({
    storage: storage,
    limits:{fileSize: 100000000000},
    /*fileFilter: function(req, file, cb){
      checkFileType(file, cb);
    }*/
  }).single('myFile');
  
  // Check File Type
  function checkFileType(file, cb){
    // Allowed ext
    const filetypes = /jpeg|jpg|png|gif/;
    // Check ext
    const extname = filetypes.test(path.extname(file.originalname).toLowerCase());
    // Check mime
    const mimetype = filetypes.test(file.mimetype);
  
    if(mimetype && extname){
      return cb(null,true);
    } else {
      cb('Error: Images Only!');
    }
  }
  
  // Init app
  const app = express();
  
  // EJS
  app.set('view engine', 'ejs');
  
  // Public Folder
  app.use(express.static('./public'));
  
  app.get('/', (req, res) => res.render('index'));
  
  app.post('/upload', (req, res) => {
    upload(req, res, (err) => {
      if(err){
        res.json({msg: err});
      } else {
        if(req.file == undefined){
          res.json({msg: 'Error: No File Selected!'});
        } else {
          res.json({msg: 'file uploaded successfully'});
        }
      }
    });
  });
  
  const port = 3000;
  
  app.listen(port, () => console.log(`Server started on port ${port}`));