如何在 JavaScript 中将图像输入与存储在我的公共文件夹中的图像进行比较?
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#pic')
.attr('src', e.target.result)
.width(600)
.height(600);
};
reader.readAsDataURL(input.files[0]);
}
}
function matching(input){
if ($('src',e.target.result)=="public_coffee.jpg") {
var x = document.createElement("IMG");
x.setAttribute("src", "public_coffee.jpg");
x.setAttribute("width", "304");
x.setAttribute("height", "228");
document.body.appendChild(x);
exit();
}
}
我对 JavaScript 很陌生。第一个功能允许我上传和查看图像并且它可以工作。第二个函数应该将上传的图像与我的公共文件夹中的图像进行比较,然后显示该图像。这第二个功能不起作用。我做错了什么或没有看到?你们能帮帮我吗?