-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
80 lines (76 loc) · 3.18 KB
/
index.html
File metadata and controls
80 lines (76 loc) · 3.18 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
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
<!DOCTYPE HTML>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp"
crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
</head>
<body>
<h1> Загрузка файла модуля на сервер</h1>
<div>Выберите модуль для загрузки на сервер</div>
<hr/>
<form name = "upload">
<input type="file" name="module" class="btn btn-default">
<input type="submit" value="Загрузить" class="btn btn-default">
</form>
<div id="downloaded"></div>
<script>
document.forms.upload.onsubmit = function()
{
var input = this.elements.module;
var file = input.files[0];
//alert(input.files[0].fileName());
//process.exit();
//var fileName = input.files[0];
if(file)
{
upload(file);
}
return false;
};
function upload(file)
{
var xhr = new XMLHttpRequest();
//обработчики событий
xhr.onload = xhr.onerror = function()
{
if(this.status == 200) {
console.log("Success!!!");
/* var new_xhr = new XMLHttpRequest();
new_xhr.onload = xhr.onerror = function()
{
if(this.status == 200) {
console.log("Success!!! recievingFIle!");
console.log(xhr.responseText);
}
else {
console.log("error"+this.status);
}
}
new_xhr.open("GET",'/uploaded',true);
new_xhr.send(null);*/
document.getElementById("downloaded").textContent = "Функции на сервере:";
document.getElementById("downloaded").textContent += xhr.responseText;
console.log(xhr.responceText);
}
else
{
console.log("error"+this.status);
}
};
xhr.open("POST","/upload?module="+file.name,true);
//var fileDescr = JSON.stringify({"Name":})
xhr.send(file);
}
</script>
</body>
</html>