I know this message is telling me the problem... but I'm just messing around with a small fun project and would like to remove the extra click that's required to open a file input when the page loads.
The following (and jsfiddle https://jsfiddle.net/qu52ksef/)
<label id="foo" for="input">Open</label>
<input id="input" name="input" type="file">
<script>
ready(function() {
document.querySelector("#foo").click();
});
function ready(fn) {
if (document.readyState != 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
</script>
This will fire the following in Chrome: File chooser dialog can only be shown with a user activation.
Is there anyway to by pass this check as a sort of 'hack'?. This won't be going into production just a little pet project I'm playing with.
Thanks,