layui单文件上传

 1     function imguload(cls) {
 2         var taskId = $("#model-taskId").val();
 3         var processInstanceId = $("#model-pid").val();
 4         var processDefinitionId = $("#model-pdid").val();
 5         upload.render({
 6             elem: cls,
 7             url: '/flow/userTaskFile/upload.cc'
 8             , xhr: xhrOnProgress
 9             , data: {
10                 "taskId": taskId,
11                 "processInstanceId": processInstanceId,
12                 "processDefinitionId": processDefinitionId
13             }
14             , auto: true
15             , progress: function (index, percent) {//上传进度回调 value进度值
16 
17             }
18             , before: function (input) {
19                 index = layer.msg('处理中', {icon: 16, shade: 0.1, time: 0});
20             }
21             , accept: 'file'
22             , done: function (res) {
23                 layer.close(index);
24                 if (res.code == 0) {
25                     layer.alert("上传成功", {
26                         icon: 1, title: '提示'
27                     });
28                 }
29                 else {
30                     layer.alert("上传失败", {
31                         icon: 2, title: '提示'
32                     });
33                 }
34             },
35             error: function () {
36                 layer.alert("上传错误", {
37                     icon: 2, title: '提示'
38                 });
39 
40             }
41         });
42     }

猜你喜欢

转载自www.cnblogs.com/yangguoe/p/9267409.html