本文的demo是参照二当家的的上传js特效http://www.erdangjiade.com/uploads/js,其中自定义上传图标就是通过webuploader上传实现。
0、请不要问“在不在”之类的问题,有问题直接问!1、学生或暂时没有工作的童鞋,整站资源免费下载!2、¥9.9充值终身VIP会员,加我微信,826096331 拉你进VIP群学习!3、程序员加油,技术改变世界。在线 充值
自定义两个上传按钮
<div class="upload-image-list clearfix">
<div class="fileinput-button js-add-image"onclick="addWebuploadCurrent($(this))">
<span class="cover_words">正面</span>
<div class="webuploader-pick">
<a class="fileinput-button-icon" href="javascript:;"></a>
</div>
</div>
<div class="fileinput-button js-add-image"onclick="addWebuploadCurrent($(this))" style="float:right">
<span class="cover_words">反面</span>
<div class="webuploader-pick">
<a class="fileinput-button-icon" href="javascript:;"></a>
</div>
</div>
</div>
webuploader多文件自定义上传
function webupload_pic() {
var maxsize = 5000;
$.getScript("./Public/js/plugins/webuploader/webuploader.js", function() {
if (!WebUploader.Uploader.support()) {
alert('您的浏览器不支持上传功能!如果你使用的是IE浏览器,请尝试升级 flash 播放器');
}
var uploader = WebUploader.create({
multiple: false,
auto: true,
swf: "./Public/js/plugins/webuploader/Uploader.swf",
server: "ajax.php",
pick: {
id: '.js-add-image',
innerHTML: ''
},
accept: {
title: 'Images',
extensions: 'gif,jpg,jpeg,png',
mimeTypes: 'image/*'
},
fileSingleSizeLimit: maxsize * 1024 * 1024,
duplicate: true,
formData: {
code: 'identity',
}
});
//上传时
uploader.on('fileQueued', function(file) {
var item_progress = "<div class='progress' id='" + file['id'] + "'><span class='bar'></span><span class='percent'>0%</span></div></li>";
$(".webupload_current").prepend(item_progress);
});
//上传中
uploader.on('uploadProgress', function(file, percentage) {
var percent = parseFloat(percentage * 100);
$("#" + file.id).find('.bar').css({"width": percent + "%"});
$("#" + file.id).find(".percent").text(percent + "%");
});
uploader.on('uploadBeforeSend', function(block, data) {
data.maxsize = maxsize;
});
//上传成功后
uploader.on('uploadSuccess', function(file, response) {
$("#" + file.id).remove();
$(".webupload_current").prepend("<img class='img_common' src=" + "./" + response.pic + " data-pic=" + response.pic + " alt='身份证照片'/>")
});
uploader.on('uploadError', function(file, reason) {
alert("上传失败!请重试。");
});
});
}
webuploader传参数
formData: {
code: 'identity',
}
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群