Search code examples
infragisticsignite-ui

Programmatically initiate file selection window on igUpload widget


  • Let's pretend we have to make a simple web page that allows users to upload files on the server.
  • When a user arrives on the page, the files selection window has to open automatically.
  • The user has to be able to select and upload multiple files at once.

igUpload control does fit nicely in this scenario.

Unfortunately, I didn't find a way to programmatically display the browse window to select a file for upload, without having to click the Upload File button. I'm using Ignite UI 13.2, which documentation could be found here and there is a related question from Infragistics forum here.

I've seen few examples, where overrides of private methods are suggested in order to modify default behavior, but currently, I couldn't find the appropriate place to intervene.


Solution

  • igUpload is using <input type="file"/> and in most browsers it is not allowed opening file selections window( via javascript ) because of security reason( Trigger a file input to open via javascript) . Probalby only IE allows you to achieve this - you can try:

    var id = "upload";
    $('#' + id).igUpload();
    setTimeout(function () {
        $('#' + id + '_ibb_fp').click();
    }, 0);