I wouldn't attempt this in the actual backend, I'd write an html form and use the API so I can utterly ignore dojo.
Here's some old js code that does this (again, as Nathan says, you probably need Enterprise to do this). If you want to follow this path, let me know, I have some more modern code hanging around that does this (you know, with fetch), but if you can wrap your head around this, you have 75% of the way there.
function addcomment(){
var formData = new FormData();
request = new XMLHttpRequest();
//WHILE THIS IS First, this only executes when the XHR/Ajax call is complete!
//Adding the file here would be pointless, we are already done talking to the server
request.onreadystatechange = function() {
if (request.readyState == 4){
if (request.status === 200) {
console.log("Create Eiffel Connect:");
console.log(request.responseText);
location.href="${VTLSERVLET_URI}?dotcache=refresh"; //reload the page
} else {
console.log("Error", request.statusText);
}
}
};
request.open("POST", "/api/content/publish/1", true);
//grab all our data from our form
var comment=document.getElementById('Comment').value;
var d=new Date();
var mon=d.getMonth()+1;
var day=d.getDate();
var atime=d.getFullYear()+"-"+mon+"-"+day+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
console.log(atime);
//Create our datablob which we will send to the API. It has to have either STname (for a new entry)
//OR the identifier of the existing object we are updating!
//This creates a new entry.
var dataObj={
'stName':'ParisContentComment',
'identifier1' : document.identifier,
'pageurl' : '$VTLSERVLET_URI',
'user' : '$reviewuser',
'useremail' : '$reviewemail',
'userdepartment' : '$reviewdept',
'userjob' : '$reviewjob',
'highlight' : document.highlit,
'comment' : comment,
'reported': atime,
'contentHost':'SYSTEM_HOST'};
formData.append('json',JSON.stringify(dataObj));
//we cannot pass the image the same way as a text field.
//GET The image.
var theimager=document.getElementById('tpic');
var file=theimager.files[0];//this also only GETS 1, this is a loop if you suppose multiples-at-once
//here we are just using the HTML input type equals file. You can get your image other ways!
if (file)
formData.append("document", file);
//append the file to our existing dataObj.
//obviously only if you have a file that has been attached.
request.send(formData);
}