0

I'm implementing a basic file upload in my Web-App and try to track the progress of the upload, but it only works if I load the App via HTTP – when I open it with HTTPS it doesn't work.

const formData = new FormData(...);
const xhr = new XMLHttpRequest();

xhr.upload.onprogress = e => {
    const progress = Math.ceil(((e.loaded) / e.total) * 100);
    ...
}

xhr.open('POST', 'https://domain/upload.', true);
xhr.send(formData);

It should return the progress if I loaded the App via HTTPS, but the event isn't even fired.

(Sidenote - maybe important?: I'm using Multer to capture the files in NodeJS)

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Tobias Gruber
  • 21
  • 2
  • 4
  • What do you get in the browser's dev tools when you inspect the XHR? What do you mean "the event isn't fired"? Are you talking about express not logging the request? –  Jan 09 '19 at 00:45

1 Answers1

0

You should check concept about XMLHttpRequest.upload. Besides, your question is a possible duplicate of this: xhr uploading progress while using expressjs multer

  • OP says code works in `http` environment but not in `https`. Your answer doesn't address that in any way. –  Jan 09 '19 at 01:22
  • Thanks for taking time to answer, I just found, that Angular-PWA was the problem, because it was somehow caching the Progress-Responses, that's also the reason, why it only occured in HTTPS :) Have a great day! – Tobias Gruber Jan 09 '19 at 01:35