-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
95 lines (94 loc) · 3.15 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
89
90
91
92
93
94
95
<!doctype html>
<html lang="zh-cn">
<head>
<title>jquery uploader demo</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fengyuanchen/[email protected]/dist/viewer.min.css">
<link rel="stylesheet" href="./css/jquery.uploader.css">
<style rel="stylesheet">
.container {
max-width: 600px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="container">
<h1>jquery-uploader</h1>
<blockquote>
一个简单的 query 文件上传,目前仅适用图片
</blockquote>
<ul>
<li>
<i>demo1 多文件上传</i>
<input type="text" id="demo1" value="">
</li>
<li>
<i>demo2 单文件上传</i>
<input type="text" id="demo2" value="">
</li>
<li>
<i>demo3 默认值</i>
<input type="text" id="demo3" value="">
</li>
<li>
<i>demo4 只读模式</i>
<input type="text" id="demo4" readonly value="">
</li>
</ul>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/fengyuanchen/[email protected]/dist/viewer.min.js"></script>
<script src="./dist/jquery.uploader.min.js"></script>
<script type="application/javascript">
let ajaxConfig = {
ajaxRequester: function (config, uploadFile, pCall, sCall, eCall) {
let progress = 0
let interval = setInterval(() => {
progress += 10;
pCall(progress)
if (progress >= 100) {
clearInterval(interval)
const windowURL = window.URL || window.webkitURL;
sCall({
data: windowURL.createObjectURL(uploadFile.file)
})
// eCall("上传异常")
}
}, 300)
}
}
$("#demo1").uploader({multiple: true, ajaxConfig: ajaxConfig, autoUpload: false})
$("#demo2").uploader({ajaxConfig: ajaxConfig})
$("#demo3").uploader({
multiple: true,
defaultValue: [
{
name: "defa",
url: "https://s2.loli.net/2022/05/07/GXrnozOj86pbFyl.jpg"
}, {
name: "file2",
url: "https://www.minecraft.net/etc.clientlibs/minecraft/clientlibs/main/resources/img/GrassBlock_HighRes.png"
}
],
ajaxConfig: ajaxConfig
})
$("#demo4").uploader({
readonly: true,
multiple: true,
defaultValue: [
{
name: "defa",
url: "https://s2.loli.net/2022/05/07/GXrnozOj86pbFyl.jpg"
}, {
name: "我的世界",
url: "https://www.minecraft.net/etc.clientlibs/minecraft/clientlibs/main/resources/img/GrassBlock_HighRes.png"
}
],
ajaxConfig: ajaxConfig
})
</script>
</body>
</html>