javascript - Convert a file to base64 using FileReader and Promises -
i wrote function use promises convert uploaded file base64 , trying return base64 string. getting http error 200 , i'm not sure if it's returning right string.
function getbase64(file) { var deferred = $.deferred(); var reader = new filereader(); reader.onload = function (event) { let base64string = reader.result.split(',').pop(); deferred.resolve(base64string); }; reader.readasdataurl(file); return deferred.promise(); };
Comments
Post a Comment