|
|
|
@ -92,9 +92,9 @@ hr{margin: 30px 0;}
|
|
|
|
|
<script src="../src/layui.js" src1="https://cdn.staticfile.org/layui/2.6.8/layui.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
layui.use(['upload', 'element'], function(){
|
|
|
|
|
var $ = layui.jquery
|
|
|
|
|
,upload = layui.upload
|
|
|
|
|
,element = layui.element;
|
|
|
|
|
var $ = layui.$;
|
|
|
|
|
var upload = layui.upload;
|
|
|
|
|
var element = layui.element;
|
|
|
|
|
|
|
|
|
|
var uploadInst = upload.render({
|
|
|
|
|
elem: '#test1'
|
|
|
|
@ -103,7 +103,7 @@ layui.use(['upload', 'element'], function(){
|
|
|
|
|
//,accept: 'file'
|
|
|
|
|
,method: 'get'
|
|
|
|
|
,fileAccept: 'image/*'
|
|
|
|
|
,exts: "jpg|png|gif|bmp|jpeg|pdf"
|
|
|
|
|
,exts: 'jpg|png|gif|bmp|jpeg|pdf'
|
|
|
|
|
,data: { //额外参数
|
|
|
|
|
a: 1
|
|
|
|
|
,b: function(){
|
|
|
|
@ -162,7 +162,8 @@ layui.use(['upload', 'element'], function(){
|
|
|
|
|
upload.render({
|
|
|
|
|
elem: '#test2'
|
|
|
|
|
,url: 'https://httpbin.org/post'
|
|
|
|
|
,multiple: true
|
|
|
|
|
,multiple: true // 多文件
|
|
|
|
|
,unified: true // 一起上传 --- 2.8.8+
|
|
|
|
|
,accept: 'images'
|
|
|
|
|
,number: 3 //同时上传的数量
|
|
|
|
|
,size: 1024
|
|
|
|
@ -176,14 +177,14 @@ layui.use(['upload', 'element'], function(){
|
|
|
|
|
}
|
|
|
|
|
,done: function(res, index){
|
|
|
|
|
// 上传完毕
|
|
|
|
|
//console.log(this.files)
|
|
|
|
|
console.log(res, index)
|
|
|
|
|
}
|
|
|
|
|
,allDone: function(obj){
|
|
|
|
|
console.log(obj)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//演示多文件列表
|
|
|
|
|
// 演示多文件列表 --- 本示例仅演示未开启 unified 属性的情况
|
|
|
|
|
var demoListView = $('#demoList');
|
|
|
|
|
var uploadListIns = upload.render({
|
|
|
|
|
elem: '#testList'
|
|
|
|
@ -247,6 +248,7 @@ layui.use(['upload', 'element'], function(){
|
|
|
|
|
}
|
|
|
|
|
,progress: function(n, elem, e, index){
|
|
|
|
|
console.log(n);
|
|
|
|
|
console.log(index);
|
|
|
|
|
element.progress('progress-'+ index, n + '%'); //进度条
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|