aguidrevitch/jquery-file-upload-middleware — pull request #30 by gsarwohadi (2013-10-12 02:30:42+00:00)
Title: Trying to fix passing formData from form to middleware

I needed to use 'formData' sent from the client and since the middleware isn't collecting it properly, I tried to make a fix.

This what I did:
Collect formData on 'field' formidable event in UploadHandler.prototype.post method to a req.fields object (created new object if undefined). Extend fileInfo with req.fields on 'end' event. So on upload.on("end", function (fileInfo)), I can have the extra property from formData in fileInfo.

Example use:

In the client:

In the server:
upload.on("end", function (fileInfo)
{
var filemanager = upload.fileManager({
targetDir: __dirname + "/public/userfiles/" + fileInfo.user_id,
targetUrl: "/userfiles/" + fileInfo.user_id
});
filemanager.move(fileInfo.name, "", function (err, result)
{
console.dir(result);
})
});