Answer the question
In order to leave comments, you need to log in
How to implement uploading files to the server with a progress bar?
I have a nodejs application with express 4.x. Something like this at the moment I am uploading files from the form to the server:
var express = require("express");
var router = express.Router();
var multipart = require("connect-multiparty");
var multipartMiddleware = multipart();
var ResourcesController = require("src/resources/resourcesController");
router.post("/saveResource", multipartMiddleware, function(req, res) {
var instance = new ResourcesController(res,req);
instance.saveResource();
});
module.exports = router;
Answer the question
In order to leave comments, you need to log in
Try using the lower level library that connect-multiparty is based on. Somehow there is progress :)
https://github.com/andrewrk/node-multiparty
var form = new multiparty.Form();
form.on('progress', function(bytesReceived, bytesExpected) {
socket.emit('received', (bytesReceived / bytesExpected).toFixed(2) * 100);
});
About a year ago I performed a similar task, although Node was version 0.12.
Used socket-io.stream and progress-stream , worked great. True, I had the task of streaming a file from the browser of one user to the browser of another with progress indication on both sides. But I think you should too.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question