Search code examples
jqueryhtmljquery-pluginsfile-uploadfileapi

jquery-html5-upload issue (Upload file on button click)


I can't get the proper way to upload a file on button click using this plugin.

https://github.com/mihaild/jquery-html5-upload

In documentation it says:

Options

Events

All events except "change" used by plugin have prefix "html5_upload.".

Events used by plugin

It is not recommended to set handlers for this events manual.

start Start upload selected files

cancelOne Cancel upload of currently uploading file

cancelAll Cancel current uploading

destroy Removes traces of plugin work

https://github.com/mihaild/jquery-html5-upload#options

I want to be able to do something like that.

$("#submit-button-1").click(function(){
$("#upload-src").html5_upload(start) //or something like that for each uploader
});

Thank you.


Solution

  • Here's the answer for your specific situation:

    jQuery('#submit-button-1').on('click',function(){
      jQuery('#upload-src').triggerHandler('html5_upload.start');
    })