Tech Tangents:Sandbox: Difference between revisions
Jump to navigation
Jump to search
(Replaced content with "<html> <script> var param = { filename: 'File_1.jpg', format: 'json', ignorewarnings: 1 }, fileInput = $( '<input/>' ).attr( 'type', 'file' ), submitBtn = $( '<input/>' ).attr( 'type', 'button' ).attr( 'value', 'Upload' ), api = new mw.Api(); $( '#bodyContent' ).append( [ fileInput, submitBtn ] ); $( submitBtn ).on( 'click', function () { api.upload( fileInput[ 0 ], param ).done( function ( data ) { console.log( data.upload.filename + ' has sucessfull...") Tag: Replaced |
No edit summary |
||
Line 1: | Line 1: | ||
<html> | <html> | ||
< | <input type="file" /> | ||
<input type="button" id="tt-button" value="Upload" /> | |||
<script> | |||
window.addEventListener("load", () => { | |||
const api = new mw.Api(); | |||
document.getElementById("tt-button", () => { | |||
let param = { | |||
filename: "File_1.jpg", | |||
format: "json", | |||
ignorewarnings: 1, | |||
}; | |||
} ); | |||
</script> | api | ||
.upload(fileInput[0], param) | |||
.done(function (data) { | |||
console.log(data.upload.filename + " has sucessfully uploaded."); | |||
}) | |||
.fail(function (data) { | |||
console.log(data); | |||
}); | |||
}); | |||
}); | |||
</script> | |||
</html> | </html> |
Revision as of 20:35, 6 September 2024