国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

javascript - 如何把前端的base64圖片上傳到阿里云oss

瀏覽:81日期:2023-10-17 10:51:08

問題描述

如何把前端的base64圖片上傳到阿里云oss

問題解答

回答1:

先把數據decode_base64, 然后通過

流式上傳就直接把解出來的內容直接上傳

文件上傳,就保存為臨時文件,再按傳統方式上傳

回答2:

你現在是獲取到了base64的圖片了嗎 如果是的話 那就調用oss對應的上傳接口不就好了 如果沒有獲取到base64格式的圖片 就用下面的辦法:

init : function(options) { var oThis = this; if( typeof FileReader===’undefined’ ) { this.imgBox.innerHTML = '抱歉,你的瀏覽器不支持 FileReader'; this.file.setAttribute(’disabled’,’disabled’); } else { this.file.addEventListener(’change’, oThis.readFile.bind(this), false); } },readFile : function(event) { var file = this.file.files[0],oThis = this;console.log(this); if ( !oThis.reg.test(file.type) ) { alert('文件必須為圖片!'); return; } var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = function(e) { var img = new Image(), 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) { var width = 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); return data;}回答3:

看這里 -- http://www.jianshu.com/p/665d...

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 汽车| 克拉玛依市| 琼结县| 谷城县| 太白县| 喜德县| 鄂州市| 通州市| 康马县| 巨野县| 德惠市| 岳普湖县| 宝坻区| 陆河县| 宁津县| 峨眉山市| 涪陵区| 登封市| 九江县| 镇沅| 玉屏| 札达县| 瓮安县| 利川市| 青铜峡市| 云南省| 安多县| 中阳县| 镇原县| 铅山县| 香格里拉县| 多伦县| 屏南县| 抚顺市| 偏关县| 济阳县| 乌鲁木齐市| 尼玛县| 五华县| 苏尼特左旗| 昌黎县|