File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -343,16 +343,17 @@ function retrieveImageFromClipboardAsBlob(pasteEvent, callback){
343
343
}
344
344
}
345
345
346
- function uploadFile ( contextPath , file , callback ) {
346
+ function uploadFile ( file , callback ) {
347
347
const xhr = new XMLHttpRequest ( ) ;
348
348
349
349
xhr . onload = function ( ) {
350
350
if ( xhr . status == 200 ) {
351
351
callback ( xhr . responseText ) ;
352
352
}
353
353
} ;
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 ) ;
356
357
xhr . setRequestHeader ( "X-Csrf-Token" , csrf ) ;
357
358
const formData = new FormData ( ) ;
358
359
formData . append ( 'file' , file , file . name ) ;
You can’t perform that action at this time.
0 commit comments