如何在同一文件中的两个图像中进行64位编码

这里我有两个表单字段,在这里我想从图像转换基本64编码,然后我想将JSON格式传递到下一个URL,我尝试这样但我没有得到,有一段时间我得到一个提交值(编码值)未捕获错误property_img,我不知道怎么做任何人帮助我请

var files = document.getElementById('floorplan_img').files; if (files.length > 0) { var file = files[0]; var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = function() { console.log(reader.result); var base64 = reader.result; var str = base64; var arr = str.split(","); var floor_img = arr[1]; console.log(floor_img); }; reader.onerror = function(error) { console.log('Error: ', error); }; } var files1 = document.getElementById('upload_properties').files; if (files1.length > 0) { var file1 = files1[0]; var reader1 = new FileReader(); reader1.readAsDataURL(file1); reader1.onload = function() { var base64_img = reader1.result; var str_64 = base64_img; var arr_str = str_64.split(","); var property_img = arr_str[1]; console.log(property_img); }; reader1.onerror = function(error) { console.log('Error: ', error); }; } 
   

试试这个:

 var reader = new FileReader(); reader.onload = function(event) { var src= event.target.result; console.log(src); };