Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload large file in express with progress bar?

Currently I am using socket.io to upload the video with progress bar. Here is the tutorial

http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-resumable-video-uploade-in-node-js/

but Internet Explorer does not support this method, but I really need upload the video in all browsers.

I checked the express documentation. Since express is based on node-formidable (which has a progress event), I think there is way to build a upload system with progress bar, right? I just don't know how!

Is node-formidable IE enabled right?

Any way is it possible to build a file upload system in pure espress.js with progress bar?

like image 273
paynestrike Avatar asked Oct 22 '12 09:10

paynestrike


People also ask

How do I upload a file to react?

In order to upload files, the 'content-type' header must be set to 'multipart/form-data'. new FormData() creates a new empty formData object that we send as the payload in our POST request. Our POST request assumes there is an API endpoint on our backend server at http://localhost:3000/uploadFile. We're done!


1 Answers

It can be done with the xhr.upload progress event. It is supported from html5.

For example: https://github.com/zeMirco/express-upload-progress

In php the upload information can be attached to the session, so it works with html4, maybe there is a nodejs extension for that too, I'll google it.

According to this: How to do upload with express in node.js there is a progress event in express by file upload, so you can set a variable in the session with the actual progress data, and read it with ajax from client side.

like image 116
inf3rno Avatar answered Sep 20 '22 12:09

inf3rno