I'm trying to use ajax file upload plugin(enter link description here) to upload a file to node.js server. This is my client side code to initialize plugin:
$(function() {
/* dom ready */
var uploader = new qq.FileUploader({
// pass the dom node (ex. $(selector)[0] for jQuery users)
element: document.getElementById('uploader'),
// path to server-side upload script
action: '/newitem',
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
sizeLimit: 10000000
});
});
My server code is
app.post('/newitem',function(req, res) {
if(req.xhr) {
console.log('Uploading...');
var fName = req.header('x-file-name');
var fSize = req.header('x-file-size');
var fType = req.header('x-file-type');
var ws = fs.createWriteStream('./'+fName)
req.on('data', function(data) {
console.log('DATA');
ws.write(data);
});
req.on('end', function() {
console.log('All Done!!!!');
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end();
});
}
});
No I can't get progress update and the uploader doesn't give failed for upload while upload success. I think this is related to ajax server response Am I right? How could I fix it?
Thanks, Feras
--
You received this message because you are subscribed to the Google Groups "Express" group.
To view this discussion on the web visit https://groups.google.com/d/msg/express-js/-/IlrHMnMEOR8J.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.
Not sure I fully understand the behavior you're getting. Are you successfully uploading files, simply not getting progress? or is the file not uploading at all?
To unsubscribe from this group, send email to express-js+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/express-js/-/DkyNFFxWuc4J.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.