猿问

如何将base64转换为image(canvas)并使用php将其保存到文件夹路径?

我对如何将base64上载到文件夹路径感到困惑。这是我的代码:


var img = document.createElement('img') || document.querySelector('img');

var context;

var width = video.offsetWidth

        , height = video.offsetHeight;


canvas = canvas || document.createElement('canvas');

canvas.width = width;

canvas.height = height;


context = canvas.getContext('2d');

context.drawImage(video, 0, 0, width, height);


img.src = canvas.toDataURL('image/png');

document.body.appendChild(img);


鸿蒙传说
浏览 256回答 2
2回答

蝴蝶刀刀

在我的代码中,我使用了它,并且有效:$picture = rtrim(strtr(base64_encode($_FILES['userfile']['name']), '+/', '-_'), '=');对于视图:img src=" echo base_url(). 'admin/assets/uploads/product/'.$product['userfile'];" alt="img" class = "img-thumbnail rounded float-left image-product"
随时随地看视频慕课网APP
我要回答