javascript - How can I trigger the upload file with Valums Ajax File-Uploader? -
when using valums ajax file uploader, how can trigger upload?
the default behavior upload begin after user selects file. want prevent happening, , instead trigger upload when user clicks separate "upload" button after have selected file.
i looked through code , found upload begins on change event attached file input. began adding return false; to onsubmit function, , attaching click event button triggered change event:
$('#startupload').on('click', function() { // conditionals $('input[name="file"]').trigger('change'); }); that doesn't work. opens file menu again.
how can prevent upload occurring after user selects file , instead trigger when user clicks button?
you have modify file-uploader.js file this. in line 309, modify onchange function return false. add following function above it, code becomes:
startupload: function(){ this._oninputchange(this._button.getinput()); }, _createuploadbutton: function(element){ var self = this; return new qq.uploadbutton({ element: element, multiple: this._options.multiple && qq.uploadhandlerxhr.issupported(), onchange: function(input){ return false; } }); }, then in html file, within button click or other event, call
uploader.startupload(); where uploader name of qq.fileuploader() object.
hope helps :)
Comments
Post a Comment