Problem
I have a straightforward file upload form. When a file is selected, how can I make it submit automatically? The user should not have to click the Submit button.
Asked by ram1
Solution #1
In the onchange event of your file input, simply call the submit method of your form.
document.getElementById("file").onchange = function() {
document.getElementById("form").submit();
};
http://jsfiddle.net/cwvc4/73/
Answered by Alex Turpin
Solution #2
Just tell the file-input to automatically submit the form on any change:
This is how the solution works:
The following are some of the benefits of this solution:
Answered by slartidan
Solution #3
Using jQuery:
Answered by Samich
Solution #4
JavaScript with onchange event:
jQuery .change() and .submit():
Answered by Alex.K.
Solution #5
The quickest answer is
<input type="file" name="file" onchange="javascript:document.getElementById('form').submit();" />
Answered by xboz
Post is based on https://stackoverflow.com/questions/7321855/how-do-i-auto-submit-an-upload-form-when-a-file-is-selected