title: Node Js Image Upload Not working
body: <p>I need to upload the image to server using node js.The image is coming from ios app as a file data. I have used the following code,</p>
  
  <pre><code> var fs = require("fs");
      var imageName = req.files.profile_image.name;
      fs.readFile(req.files.profile_image.path, function (err, data) {
      console.log(imageName);
      // If there's an error
      if(!imageName){
        console.log("There was an error")
        //res.redirect("/");
        //res.end();
      } else {
          console.log(data);
        var newPath = 'http://example.com/images/' + imageName;
        // write file to uploads/fullsize folder
        fs.writeFile(newPath, data, function (err) {
          // let's see it
          console.log(err);
          //res.redirect("http://example.com/images/" + imageName);
        });
      }
    });
  </code></pre>
  
  <p>When I run this code, I have received no error but the image is not uploaded in images folder.</p>
  
  <p>I am getting the following error with fs.writeFile,</p>
  
  <pre><code>   { Error: ENOENT: no such file or directory, open 'http://example.com/images/user-profile.jpg'
      at Error (native)
    errno: -2,
    code: 'ENOENT',
    syscall: 'open',
    path: 'http://example.com/images/user-profile.jpg' }
  </code></pre>
  
  <p>Please help.</p>