Luciuz Luciuz - 5 months ago 46
HTML Question

How open select file dialog via js?


It doesn't work on Chrome 26 on Mac OS =(

The problem actually is creation "upload" widget that can be integrated in a form.
Widget will consists of two parts. The first part is div with initiator button and error/success messages.
I think the way is put another form as the second part with file input and submit file into the iframe. After submition we fill hidden field in first part in main form or show errors in the same.

Easy way is adding file-form into main-form, but it's prohibited.

Fix me.


I would create an input like this

<button id="id">Open</button>
<input id="yourinputname" type="file" name="yourinputname" style="display: none;" />

and some jQuery to trigger it:

$('#id').on('click', function() {