You cannot post your image to the server like that. Javascript won't allow you to.
Take a look at some existing components that upload files asynchonously, it's complicated because of client side permissions & stuff. I like
dropzone.js[
^] for upload files using javascript.