layui单文件上传

本文介绍了一个使用特定库实现的文件上传功能,并包含了上传进度的实时显示。通过设置不同的参数,如任务ID、实例ID等,可以针对不同场景进行文件上传操作。同时,文章还详细展示了如何处理上传过程中的各种状态反馈。
 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     }

 

转载于:https://www.cnblogs.com/yangguoe/p/9267409.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值