Skip to content

Commit e320c53

Browse files
committed
adapt uploadFile
1 parent f324d05 commit e320c53

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

public/js/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,17 @@ function retrieveImageFromClipboardAsBlob(pasteEvent, callback){
343343
}
344344
}
345345

346-
function uploadFile(contextPath, file, callback) {
346+
function uploadFile(file, callback) {
347347
const xhr = new XMLHttpRequest();
348348

349349
xhr.onload = function() {
350350
if (xhr.status == 200) {
351351
callback(xhr.responseText);
352352
}
353353
};
354-
//TODO contextPath
355-
xhr.open("post", suburl + "/" + contextPath + "/attachments", true);
354+
let contextPath = window.location.pathname.substr(suburl.length).replace(/^\/+$/g, '');
355+
let contextPathArray = contextPath.split('/');
356+
xhr.open("post", suburl + "/" + contextPathArray[0] + "/" + contextPathArray[1] + "/attachments", true);
356357
xhr.setRequestHeader("X-Csrf-Token", csrf);
357358
const formData = new FormData();
358359
formData.append('file', file, file.name);

0 commit comments

Comments
 (0)