-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileUpload.htm
61 lines (57 loc) · 2.61 KB
/
FileUpload.htm
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>上传本体</title>
<link rel="stylesheet" type="text/css" href="js/layui-2.2/css/layui.css" />
<script type="text/javascript" src="js/layui-2.2/layui.js" charset="utf-8"></script>
</head>
<body>
<div style="margin:40px 40px 0 40px;">
<blockquote class="layui-elem-quote">
Single uploading ontology file size cannot exceed 20M, supported file types such as
<span class="layui-badge">OWL</span>
<span class="layui-badge">RDF</span>
<span class="layui-badge">XML</span>
</blockquote>
<form class="layui-form" method="post" action="UploadServlet">
<div class="layui-form-item">
<label class="layui-form-label">Select File</label>
<button type="button" class="layui-btn layui-btn-warm" id="up-btn">
<i class="layui-icon"></i> Upload File
</button>
</div>
<hr/>
</form>
</div>
<script type="text/javascript">
var uploadedFile;
layui.use(['element', 'layer', 'form', 'upload'], function () {
var upload = layui.upload;
var uploadInst = upload.render({
elem: '#up-btn' //绑定元素
, url: 'UploadServlet' //上传接口
, data:{mType: 'owl' }
, accept: 'file'
, size: 20000 //单位KB
, exts : 'owl|rdf|xml'
, done: function (res, index, upload) { //上传完毕回调
if (res != "0" && res!="4") {
uploadedFile = res.file;
layer.msg(uploadedFile+" Uploaded successfully!", { icon: 1 });
}
else if (res == "4") {
layer.msg("Error: Table must contain enctype=multipart/form-data", { icon: 2 });
}
else {
layer.msg(" Upload failed!", { icon: 2 });
}
}
, error: function () {//请求异常回调
layer.alert(" Upload failed!", { icon: 2 });
}
});
})
</script>
</body>
</html>