I've been struggling to find a proper method for posting a file selected using dojox.form.Uploader
to my servlet. Unfortunately, there is limited documentation available for Dojo and not many examples, demos, or tutorials to follow. Any help with this would be greatly appreciated.
Here is the code snippet in JSP:
<tr>
<td colspan="9"><h2>File Upload<br /></h2><h3>To add 800#s using a file</h3></td>
</tr>
<tr>
<td colspan="9"><input type="file" data-dojo-type="dojox.form.Uploader" label ="Browse" multiple="false" id="uploader" onchange="check();" uploadOnSelect="true" url="/MyProject/app/ActionRequestHandlerServlet"/>
<div id="files" data-dojo-type="dojox.form.uploader.FileList" uploaderId="uploader" ></div>
</td>
</tr>`
Below is the JavaScript code that is used:
function check() {
alert(dijit.byId("uploader").value);
formPostObject.file = dijit.byId("uploader").value;
sendFile();
}
function sendFile() {
dojo.io.iframe.send({
url: "/MyProject/app/ActionRequestHandlerServlet", // Replace with yours
method: "post",
handleAs: "text",
form: dojo.byId("uploader"),
load: function(response, ioArgs) {
console.log("Upload OK", response, ioArgs);
return response;
},
error: function(response, ioArgs) {
console.log("Upload FAILED!!!", response, ioArgs);
return response;
}
});
}
Despite implementing the above code, I am not getting any response. The sysout statements in my servlet are also not being printed. Additionally, I'm encountering a JavaScript error in dojo.js -> 'length' is null or not an object, even though I'm not using 'length' anywhere in my code.
If anyone could provide assistance, it would be greatly appreciated. Thank you in advance.