I would like to use dojox/form/Uploader and post some additional data to upload url. I tried to use submit() method to submit the form in which upload lays, I set uploader uploadOnSelect: false but was not able to catch the file choose event to trigger the submit() function. My html looks like this:
<form id="myform" method="post" enctype="multipart/form-data">
<input type="hidden" name="message" value="something" >
<div id="uploader"></div>
</form>
And my upload js looks like this:
require(['dojox/form/Uploader',"dojo/dom",
"dojox/form/uploader/plugins/IFrame",
"dojo/domReady!"], function(Uploader, dom){
myUploader = new Uploader({
label: "Select files",
multiple: false,
uploadOnSelect: false,
url: "UploadFile"
}, "uploader");
myUploader.startup();
});
Where should I put the myUploader.submit(); function for uploader to submit on file choose?
Try this :
// [...]
myUploader.on('change', function(){
uploader.submit(dom.byId("myform"));
});
myUploader.startup();