梵蒂冈之花
你现在是获取到了base64的图片了吗如果是的话那就调用oss对应的上传接口不就好了如果没有获取到base64格式的图片就用下面的办法:init:function(options){varoThis=this;if(typeofFileReader==='undefined'){this.imgBox.innerHTML="抱歉,你的浏览器不支持FileReader";this.file.setAttribute('disabled','disabled');}else{this.file.addEventListener('change',oThis.readFile.bind(this),false);}},readFile:function(event){varfile=this.file.files[0],oThis=this;console.log(this);if(!oThis.reg.test(file.type)){alert("文件必须为图片!");return;}varreader=newFileReader();reader.readAsDataURL(file);reader.onload=function(e){varimg=newImage(),length=this.result.length,result=this.result;img.src=result;img.onload=function(){if(length>oThis.maxSize){result=oThis.compress(img);}oThis.imgBox.src=result;oThis.cb(result);};}},compress:function(img){varwidth=img.width,height=img.height,data=null;this.canvas.width=img.width;this.canvas.height=img.height;this.ctx.drawImage(img,0,0,width,height);data=this.canvas.toDataURL('image/jpeg',this.ratio);returndata;}