lundi 12 janvier 2015

node.js / image upload using express / transfer not complete


I'm trying to upload an image using ajax / node.js and express 3 (included Formidable)


The transfert is ok but not complete ... It missing a part of the image as you can see on this screenshot (the dark area)


image cut screenshot


This is the server post route code :



var form = req.form;

form.uploadDir = __dirname + '/client/tmp';
form.maxFieldsSize = 20 * 1024 * 1024;
form.keepExtensions = true;

form.parse(req, function(err, fields, files) {
if (err) return console.log(err);

console.log('ok !');
});


EDIT


The weight of the uploaded image is bigger than original ... example : I try to upload a 80ko image, and the uploaded file have a weight of 140ko (and is not complete)


EDIT 2


If I use



form.on('file', function(name, file) {
});


Instead of



form.parse ...


It works, but don't know why ...


Any help would be very appreciated





Aucun commentaire:

Enregistrer un commentaire