【发布时间】:2016-08-26 12:47:14
【问题描述】:
我有一张来自 PHP 数据库的图片,是这种格式的
<img src="data:image/jpeg;base64,{{base64_encode($file)}}"/>
//I am able to see the image in this tag
现在使用 onclick 功能来编辑附加信息,用户也可以更改图像,但为此我需要读取此图像,单击时应将其粘贴到具有此 id 的图像标签中
<img style="max-width:400px;" src="" id="imgretprd">
我研究了一下,才知道这段代码
var reader = new FileReader();
reader.addEventListener("load", function () {
preview.src = reader.result;
}, false);
if (file) {
reader.readAsDataURL(file);
}
但我不知道如何使用它。
【问题讨论】:
标签: javascript php image