I want to upload files from client to server and then store them in a folder corresponding to the user that uploaded that particulart file! The code seems to be ok, but the problem seems to be fs-related! Fs only transfers 15 bytes of the file. In fact it only transfers 15 bytes of every file type I have tried so far (images and videos)! This is my code so far, can you please help me? Thank you!
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
app.post('/upload', multipartMiddleware, function(req, res){
var file = req.files.thumbnail; // that's what I've named the html input element
var stream = fs.createWriteStream(file.path);
fs.writeFile('./users/'+req.user._id+'/'+file.originalFilename, stream);
res.redirect('/');
});