-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
54 lines (46 loc) · 1.47 KB
/
Copy pathapp.js
File metadata and controls
54 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* ==========================================
SHOW UPLOADED IMAGE
* ========================================== */
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imageResult')
.attr('src', e.target.result);
};
reader.readAsDataURL(input.files[0]);
}
}
$(function () {
$('#upload').on('change', function () {
readURL(input);
});
});
/* ==========================================
SHOW UPLOADED IMAGE NAME
* ========================================== */
var input = document.getElementById( 'upload' );
var infoArea = document.getElementById( 'upload-label' );
input.addEventListener( 'change', showFileName );
function showFileName( event ) {
var input = event.srcElement;
var fileName = input.files[0].name;
infoArea.textContent = 'File name: ' + fileName;
}
function formSubmit(e) {
e.preventDefault();
var formData = new FormData();
var imagefile = upload = $("#upload")[0];
const url = "http://192.168.0.66:4545/api/digit/recognition/"
formData.append("image", imagefile.files[0]);
axios.post(url, formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
}).then((response)=>{
if ($("#result").get(0).classList.contains("d-none")) {
$("#result").toggleClass("d-none");
}
$("#number").text(response.data[0][1]);
})
}