I'm attempting to create a server-side upload component in node.js, but I'm having trouble interpreting the information sent from PLUpload. From what I can tell, PLUpload (in HTML5 mode) sends files as binary information, which creates problems for the node.js packages I've been attempting to use so far (node-formidable and node-express), as they expect normal HTML uploads with multipart content types.
For what it's worth, this is the code I've been attempting to use...
var formidable = require('formidable');
var sys = require('sys');
http.createServer( function( req, res ){
console.log('request detected');
if( req.url == '/upload/' ){
console.log('request processing');
var form = new formidable.IncomingForm();
form.parse( req, function( err, fields, files ){
res.writeHead( 200, {
'Access-Control-Allow-Origin': 'http://tksync.com',
'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE',
'Access-Control-Allow-Headers': '*',
'content-type': 'text/plain'
});
res.write('received upload:\n');
res.end(sys.inspect({
fields: fields,
files: files
}));
});
}
}).listen( 8080 );
I created
node-pluploader
to handle this, as I found elife's answer didn't work for chunked uploads, as said chunks come in on different requests.Express-based usage example:
I have no problem to use plupload(in HTML5 mode) with node.js with below code: