webuploader上传插件封装,带编辑回显

环境:jquery1.9+ ,layui ,webuploader

1.前端:


<div id="upload-box"></div>
<div class="col-lg-2">
	<button id="upload" type="button" class="btn btn-info"><i class="fa fa-upload"></i> 上传</button>
</div>


2.upload.js

var uploader = $('#upload-box').uploader({
	
	server: root +'file/uploadPic',		// 上传文件接口
	deleteServer:'',					// 删除文件接口
	md5Server:'',						// md5秒传验证接口
	isRealTimeDelete:false,				// 删除已上传的文件,是否需要实时删除,true则需要提供删除文件接口
//	eventAddFileErrorCustom:true,
	//添加文件出错
//	addFileError:function(type,arg1,arg2){
//		console.log('addFileError')
//	},
	//在添加文件前执行true或无返回值则放过,false则不放过
	beforeFileQueued:function(file){
		console.log('beforeFileQueued')
		console.log(file)
		return true;//false 不添加
	},
	//当有文件被添加进队列的时候执行
	fileQueued:function(file){
		console.log('fileQueued')
		console.log(file)
	},
	//文件上传过程中创建进度条实时显示
	uploadProgress:function(file, percentage){
		console.log(file);
		console.log(percentage);
		console.log('uploadProgress')
	},
	//文件上传成功
	uploadSuccess:function(file, response){
		console.log(file);
		console.log(response);
		console.log('uploadSuccess')
	},
	//文件上传失败
	uploadError:function(file){
		console.log(file);
		console.log('uploadError')
	},
	//文件全部上传成功
	uploadFinished:function(file,data){
		console.log(file);
		console.log(data);
		console.log('uploadFinished');
	}
});

$('#upload').on('click',function(){
	uploader.upload();
})

3.效果:





4.如果有什么补充和修改的地方  到webuploader/uploader.js里修改

或者联系本人 e-mail: 595324626@qq.com

5.插件下载地址https://download.csdn.net/download/k21325/10291247

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值