javascript - How open select file dialog via js? -


$('#id').click(); 

it doesn't work on chrome 26 on mac os =(

the problem creation "upload" widget can integrated in form. widget consists of 2 parts. first part div initiator button , error/success messages. think way put form second part file input , submit file iframe. after submition fill hidden field in first part in main form or show errors in same.

easy way adding file-form main-form, it's prohibited.

fix me.

using jquery

i create input this

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

and jquery trigger it:

$('#button').on('click', function() {     $('#file-input').trigger('click'); }); 

using vanilla js

or when don't want jquery vanilla js example (credits @pascale)

<button onclick="document.getelementbyid('file-input').click();">open</button> <input id="file-input" type="file" name="name" style="display: none;" /> 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -