<form class="upHuzhaoImg1" id="myform2" method="post" action="http://upload-z1.qiniu.com" enctype="multipart/form-data"> <input class="getTime2" name="key" type="hidden" value=""> <input name="x:<custom_name>" type="hidden" value=""> <input class="tokenUrl2" name="token" type="hidden" value=""> <input onclick="fileClickFun(2,1)" id="upInput2" class="upVideoInput2" style="margin:0;" class="upVideo" name="file" type="file" accept="image/*" value=""/> <input name="accept" type="hidden" value="" /> </form>
function fileClickFun(i,num){ var date =new Date().getTime(); $('.getTime'+i).val(date); $(".upVideoInput"+i).change(function(){ var formData = new FormData($("#myform"+i)[0]); $.ajax({ url:"http://upload-z1.qiniu.com", type:"post", data: formData, async: false, cache: false, contentType: false, processData: false, success:function(data){ if (num == 1) { $('.huzhao').attr('src','http://cdn.yinyuewujie.com/'+data.key); $('.huzhao').attr('abc','/'+data.key); $('.upImgBtn').html('更换个人护照照片页'); }else if(num == 2){ $('.headingImg').attr('src','http://cdn.yinyuewujie.com/'+data.key); $('.headingImg').attr('abc','/'+data.key); } }, error:function(e){ alert("错误!!"); } }); }); }
//获取上传到七牛自己的库里的token
function tokenFun(i){
$.ajax({
url:httpB+'/zr/web/tWXplayer/getUpload_Token.do',
type:'POST',
success:function(data){
if (data.code == 0) {
console.log(data);
$('.tokenUrl'+i).val(data.data.upload_token);
}
}
})
}