diff --git a/src/index.html b/src/index.html index 592b811..e330dbc 100644 --- a/src/index.html +++ b/src/index.html @@ -45,20 +45,21 @@ class Uploader { idx = 0; file; - path; $elem; constructor(idx, file) { this.idx = idx; this.file = file; - this.path = location.pathname + "/" + file.name; } upload() { - const { file, idx, path } = this; + const { file, idx } = this; + let url = location.href.split('?')[0]; + if (!url.endsWith("/")) url += "/"; + url += encodeURI(file.name); $uploaders.insertAdjacentHTML("beforeend", `
`); this.$elem = document.getElementById(`file${idx}`); @@ -67,7 +68,7 @@ ajax.addEventListener("load", e => this.complete(e), false); ajax.addEventListener("error", e => this.fail(e), false); ajax.addEventListener("abort", e => this.fail(e), false); - ajax.open("PUT", path); + ajax.open("PUT", url); ajax.send(file); }