title: nodejs how to upload image from API
body: <p>I am new to node JS and i have made function for uploading image from API.
  But when i hit the URL from postman using form-data having field name image then in response it shows me.
  <a href="https://i.stack.imgur.com/ArOfk.png" rel="nofollow noreferrer">Here is the postman image</a></p>
  
  <blockquote>
    <p>Error uploading file</p>
  </blockquote>
  
  <p>below is my code</p>
  
  <p>My router.js contain:- </p>
  
  <pre><code>var express = require('express');
  
  var router = express.Router();
  
  var ctrlSteuern = require('../controllers/steuern.controllers.js');
  </code></pre>
  
  <p>router</p>
  
  <pre><code> .route('/steuern/image_upload')
   .post(ctrlSteuern.imageUpload);
  </code></pre>
  
  <p>in Controller i have:-</p>
  
  <pre><code>var multer = require('multer'); 
  
  var multiparty = require('multiparty');
  
  var storage =   multer.diskStorage({
  
  destination: function (req, file, callback) {
  
  callback(null, './image');
  
  },
  
  filename: function (req, file, callback) {
  
  callback(null, file.fieldname + '-' + Date.now());
  
  }
  
  });
  
  var upload = multer({ storage : storage}).single('image');
  
  module.exports.imageUpload = function(req, res){
  
  upload(req,res,function(err) {
  
  if(err) {
  
  return res.end("Error uploading file.");
  
  }
  
  return res.end("File is uploaded");
  
  });
  
  }
  </code></pre>