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
|
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>rhimportd File Upload</title>
<style type="text/css">
body {
background-color: #555;
}
div.data {
background-color: white;
border: 1px solid;
padding: 1em;
font-family: monospace;
margin-top: 1em;
margin-bottom: 1em;
}
td.label {
text-align: right;
}
</style>
<script src="jquery.min.js"></script>
<script type="text/javascript">
function upload() {
$('#buttonupload').attr('disabled','disabled');
$('#result').empty();
var command = {
type: "POST",
contentType: "application/octet-stream",
data: $('#file').get(0).files[0],
processData: false,
dataType: 'json',
error: function(req, status, err) { result({StatusText: status, ErrorString: err}); },
success: function(data, status, req) { result(data); }
};
$.ajax('/public/upload/' + $('#username').val() + '/' + $('#sessionid').val(), command);
}
function result(data) {
$('#result').text(JSON.stringify(data));
$('#buttonupload').removeAttr('disabled','disabled');
}
function init() {
$('#sessionid').val("");
result({})
}
</script>
</head>
<body onload="init()">
<div class="container">
<h1>rhimportd File Upload</h1>
<table>
<tr><td class="label">Username</td><td><input id="username" type="text" size="20" value="heslinki" /></td></tr>
<tr><td class="label">Session</td><td><input id="sessionid" type="text" size="45" /></td></tr>
<tr><td class="label">File</td><td><input id="file" type="file" /></td></tr>
<tr><td> </td><td><button id="buttonupload" onclick="upload()">upload</button></td></tr>
</table>
<div id="result" class="data"></div>
</div>
</body>
</html>
|