How to convert image to byte array using javascript only to store image on sql server?

后端 未结 3 1385

I am struggling converting image to byte array using client side script. I have to convert image to byte array, and pass this array to web service , so that the web services

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 13:03

    File.prototype.convertToBase64 = function(callback){
    
        var FR= new FileReader();
        FR.onload = function(e) {
             callback(e.target.result)
        };       
        FR.readAsDataURL(this);
    }
    

    and later call this function using this

    var selectedFile = this.files[0];
    selectedFile.convertToBase64(function(base64)
    

    you get your base64 code.

提交回复
热议问题