mardi 10 février 2015

Upload image without form using javascript?

I'm looking for the most streamlined way of uploading images to insert them into a text that a user is typing.


So while the user is typing into a textarea I want him to be able to click an icon which will open the file browsing dialog of the browser. After choosing an image I want it to be uploaded automatically and have the url inserted in the text field.


Unfortunately I don't really have an idea how to solve this.


One idea is to use a hidden file input field and 'click' it using js. But how can i submit the hidden form after an image got chosen without the need of an additional submit button?


EDIT: Of course I want to archive this using ajax. The server side should be easy as it just receives the data and returns the URL. What I need to know is how to trigger the file browser dialog and then trigger the ajax request when the user presses "open".





Aucun commentaire:

Enregistrer un commentaire