js将图片转化为二进制流

<input accept="image/*" class="fileImg" type="file" />

$('.fileImg').change(function () { 
var f = this.files[0]; 
var FR = new FileReader(); 
FR.onload = function (e) { 
 var imgData = this.result; 
if (imgData.indexOf(":image/jpeg;") != -1) { 
 imgData = imgData.replace("data:image/jpeg;base64,", ""); 
} else { 
 imgData = imgData.replace("data:image/png;base64,", ""); 
} 
console.info("二进制图片流:"+imgData );
}; 
FR.readAsDataURL(f); 
});
正在加载评论...