I'm using this plugin: jQuery HTML5 uploader (see the demo), inside a form. I want to send uploaded files with the POST method when user submit the form.
Maybe can I create a input[type="file"]
, make it hidden, and dynamically add uploaded files with the plugin inside the input? It is possible?
So, if I can't do that, how can I upload files to server with this plugin, only when user click on the submit button? I know that the plugin it's already doing that with AJAX, but I want to upload them only if user clicks on a button.
Maybe should I create a variable named for example files
and, when user clicks on the submit button use AJAX myself to send files and the rest of inputs data?
Something like this:
jQuery( "#dropbox" ).html5Uploader({
onClientLoadStart: function( event, file ) {
files[] = file;
[...]
}
});
[...]
jQuery("#button").on("click", function() {
jQuery.ajax({
data: files
});
[...]
});