diff --git a/src/dropzone.js b/src/dropzone.js index 56d9d8d28..d50b8c739 100644 --- a/src/dropzone.js +++ b/src/dropzone.js @@ -740,7 +740,7 @@ export default class Dropzone extends Emitter { addFile(file) { file.upload = { // note: this only works if window.isSecureContext is true, which includes localhost in http - uuid: self.crypto.randomUUID(), + uuid: window.isSecureContext ? self.crypto.randomUUID() : Dropzone.uuidv4(), progress: 0, // Setting the total upload size to file.size for the beginning // It's actual different than the size to be transmitted. @@ -1707,6 +1707,17 @@ export default class Dropzone extends Emitter { return this.processQueue(); } } + + static uuidv4() { + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace( + /[xy]/g, + function (c) { + let r = (Math.random() * 16) | 0, + v = c === "x" ? r : (r & 0x3) | 0x8; + return v.toString(16); + } + ); + } } Dropzone.initClass();