我们有一个本地系统,我想制作一个从中提取图像(' http://localhost/system_analysis.png ')并发送到 php 脚本的页面。
我有这个使用 FileReader 类的代码:
function fileAsDataURL(file) {
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function () {
return (reader.result;
};
reader.onerror = function (error) {
return 0;
};
}
var xhr = new XMLHttpRequest();
xhr.open("POST", MY_API, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
value: fileAsDataURL('http://localhost/system_analysis.png')
}));
我试过了,但我无法让它工作
慕容3067478
相关分类