I have a form whose only purpose is to upload files, but for user experience reasons, I need a nice-looking button that:
- loads the file dialog
- auto-submits the form when a file has been selected
The original solution was something like this JSFiddle, where you have a link that loads the file dialog, then listens for the dialog's change
event to auto-submit the form:
$("input[type=file]").on("change", function () {
// auto-submit form
$("form").submit();
});
$("#my-nice-looking-button").on("click", function (e) {
e.preventDefault();
// load file dialog
$("input[type=file]").trigger("click");
});
If you try that fiddle, it will work in IE9, Chrome, Firefox, etc., but it doesn't work in Internet Explorer 10. All the JavaScript functionality works, including the form's submit
event getting fired. But, the browser never POSTs the form data to the server; it just sits there.
Is there some security safeguard or file upload limitation built into IE10 that prevents this from working?