ash-f
ash-f

Reputation: 53

show upload dialog immediately when open a page using javascript

This code works on Firefox, but does not work on Mac/iOS Safari. Is there a way to make it work?

$(function(){ 
setTimeout(function(){ $("input[name='upload']").trigger('click'); },1000);
});

Upvotes: 0

Views: 51

Answers (2)

ash-f
ash-f

Reputation: 53

Apparently that's prohibited. probably in terms of security. https://mariusschulz.com/blog/programmatically-opening-a-file-dialog-with-javascript

Upvotes: 1

Victor Luna
Victor Luna

Reputation: 1814

not sure if this will work, but maybe you can try.

Add this meta tag at the top

<meta name="apple-mobile-web-app-capable" content="yes">

And for the input field maybe try

<input accept="image/png,image/gif,image/jpeg" type="file" name="upload" />

Hope this helps!

Upvotes: 1

Related Questions