bombastic
bombastic

Reputation: 3061

JS - html5 file reader API - get file as binary string and send it via ajax

i'm trying getting binary string of the files but as i can see i'm unable actually, why readAsDataUrl works while readAsBinaryString won't ?

I putted my code in jsbin any help appriciated thanks.

updated jsbin

Upvotes: 0

Views: 458

Answers (1)

Ricola3D
Ricola3D

Reputation: 2442

img.src = e.target.result;

Dude, the "src" attribute of an image is a URL, not a string where every character is an int between 0 and 255 !!

You have to use ReadAsArrayBuffer() instead, and then the canvas API to render the ArrayBuffer you have into the context of a canvas.

Edit: If you don't want to show it in an image, but just to Ajax it to your server, here is a solution !

Upvotes: 1

Related Questions