1$('#input-file').change(function() {
2
3 var url = '/back-end-url';
4 var form_data = new FormData();
5 var xhr = new XMLHttpRequest();
6
7 $.each(this.files, function (key, value) {
8 form_data.append('file', value)
9 })
10
11 xhr.open('POST', url, true)
12 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")
13 xhr.send(form_data)
14
15 xhr.onreadystatechange(function() {
16 if(xhr.readyState == XMLHttpRequest.DONE) {
17 var res = JSON.parse(xhr.responseText)
18 }
19 })
20
21})
22