Pano Pano - 5 months ago 28
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?


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;