本帖最后由 伟伟 于 2022-4-19 13:31 编辑
我这个码不是上传的图片,是页面生成的,
var img = Forguncy.Page.getCell("jpg").getValue();
function getBase64Image(img) {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, img.width, img.height);
var ext = img.src.substring(img.src.lastIndexOf(".")+1).toLowerCase();
var dataURL = canvas.toDataURL("image/"+ext);
return dataURL;
}
var image = new Image();
image.src = img;
image.onload = function(){
var base64 = getBase64Image(image);
console.log(base64);
Forguncy.Page.getCell('touxiang').setValue(base64);
}
|