Monday, May 14, 2012

error upload file with node.js


var formidable = require('formidable')
, http = require('http')
, util = require('util');

app.get('/song/add', function(req, res){

res.writeHead(200, {'content-type': 'text/html'});
'<form action="/song/upload" enctype="multipart/form-data" method="post">'+
'<input type="text" name="title"><br>'+
'<input type="file" name="upload" multiple="multiple"><br>'+
'<input type="submit" value="Upload">'+
});'/song/upload', function(req, res){

var form = new formidable.IncomingForm();
form.parse(req, function(err, fields, files) {
res.writeHead(200, {'content-type': 'text/plain'});
res.write('received upload:\n\n');
res.end(util.inspect({fields: fields, files: files}));

Now when I try uploading the file, the browser just keep loading forever.....

No comments:

Post a Comment