Pano Pano - 1 year ago 77
Javascript Question

where is object stored in xmlhttprequest


var test_request = new XMLHttpRequest();"POST","/testupload",true);

Node.js express:"/testupload", function(req, res){
where is the image.sourceFile in req?

where is the image.sourceFile in req? req.body shows {}, how can I get the image?

Answer Source

if you want to the form data of a POST request, you should try to use body-parser middleware first.

const express        = require('express');
const bodyParser     = require('body-parser');
const app            = express();
app.use(bodyParser.urlencoded({ extended: true, type: 'application/x-www-form-urlencoded' }));

now you can get form data in req.body;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download