-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
88 lines (86 loc) · 3.2 KB
/
index.html
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>FileKip</title>
<link rel="stylesheet" href="semantic/dist/semantic.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="ui container">
<img class="ui centered image" src="img/logo.png" alt="logo" srcset="">
</div>
<div class="ui horizontal divider">
<i class="file icon"></i>
</div>
<div class="ui container">
<div class="ui secondary pointing two item menu">
<a class="active item filemenu" href="/">
Upload A File
</a>
<a class="ui item filemenu" href="/download">
Download A File
</a>
</div>
<div class="ui segment">
<div class="ui centered huge header"> Select a File to Upload </div>
<form class="ui form" role="form" onsubmit="return false">
<div class="ui field icon input">
<input class="ui input" id="file" type="file">
<i class="file icon"></i>
</div>
<div class="field centered">
<button id="upload" type="button" class="ui basic secondary button"> <i class="icon upload"></i> Upload </button>
</div>
</form>
<div class="ui centered hude header"> Progress: </div>
<div>
<div class="ui indicating progress" data-percent="0" id="progress">
<div class="bar">
<div class="progress"></div>
</div>
<div class="label" id="output"></div>
</div>
<div id="loader" class="ui inline loader"></div>
</div>
</div>
</div>
</body>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="/semantic/dist/semantic.min.js"></script>
<script src="js/axios.js"></script>
<script>
var output = document.getElementById('output');
var loader = document.getElementById('loader');
document.getElementById('upload').onclick = function(){
console.log("you clicked button")
output.innerText = ""
var data = new FormData();
data.append('file',document.getElementById('file').files[0]);
var config = {
// this function will run during the upload process and will be fired every second during upload
onUploadProgress: function(progressEvent){
var percentCompleted = Math.round( (progressEvent.loaded * 100) / progressEvent.total );
$('#progress').progress({
percent: percentCompleted
});
if(percentCompleted == 100){
$('#loader').addClass("active centered")
output.innerText = "Processing File"
}
}
};
axios.post('/upload',data,config)
.then(function(res){
$('#loader').removeClass("active centered")
output.innerText = res.data;
})
.catch(function(err){
output.className = 'container text-danger';
output.innerText = err.message;
})
}
</script>
</html