I have this line in HTML:
<input class="input-file" type="file" id="input-recipe-pic">
After a user selects a file to upload, and presses the submit button, I am trying to get the file they selected from the file input tag above. How can I get the file with javascript so I can later send it by AJAX to avoid a page reload?
This was not possible without iframe hacks until the advent of the HTML5 File API. Using the HTML5 File API, you can do
Note that this will only work on browsers that support the HTML5 File API, such as Chrome.