I am trying to to send a base64 encoded img to server,the javascript looks like
var xhr=new XMLHttpRequest()
var reader=new FileReader()
reader.on
reader.readAsDataURL(file)
A data URL is NOT the same as a base64 version of the file. You get extra garbage in it. It looks like this:
data:[<MIME-type>][;charset=<encoding>][;base64],<data>
See Wikipedia.
Try doing a simple regex on it:
var data = dataURL.match(/,(.*)$/)[1];
Or, in your code,
xhr.send(e.target.result.match(/,(.*)$/)[1]);