Maple
Maple

Reputation: 51

Displaying correct upload progress

I am using XMLHttpRequest to POST 400-500k files to relatively slow ESP32-based server. The upload takes several minutes. The xhr.onreadystatechange event with readyState 4 fires at the end as expected. However xhr.upload.onprogress event that updates progress bar fires almost immediately with 100% complete.

I suspect some buffer in the many layers between the browser and the application's HTTP handler absorbs entire file, making it look like it has been transmitted already.

The code here is very close to what I am doing and apparently it works for the author. Could be because the files are much bigger and server faster.

Upvotes: 0

Views: 33

Answers (1)

Itsyobestnugget
Itsyobestnugget

Reputation: 1

i dont have much expirience with the actual code but I do know how it works. basically a post request will send back a data complete as soon as its done. what you could do is send a request for progress percentage very few seconds and wait for a response back. when you get that response update it in the HTML. I'm new to this website so sorry if I'm not much of a help. if its a buffer that absorbs the file. you could also send it byte by byte and have a system autorun on the server to compile it all together in the end and make it one file. otherwise I don't know how to help. like I said I'm new so sorry if I'm no help. i just want to try if I can :(

Upvotes: 0

Related Questions