其他分享
首页 > 其他分享> > 图片上传时base64转成formData

图片上传时base64转成formData

作者:互联网


export const base64ToBlobios = (base64Str) => {
let byteCharacters = atob(base64Str);
let byteNumbers = new ArrayBuffer(byteCharacters.length);
let byteArray = new Uint8Array(byteNumbers);
for (let i = 0; i < byteCharacters.length; i++) {
byteArray[i] = byteCharacters.charCodeAt(i);
}
let blob = new Blob([byteNumbers], { type: "image/jpeg" });
let formData = new FormData();
formData.append("file", blob, new Date().getTime() + ".png");
return formData;
}

标签:byteCharacters,base64Str,formData,base64,byteNumbers,let,转成,new
来源: https://www.cnblogs.com/aquackw/p/16243041.html