Currently, I am developing an express web application with a Parse backend. To render webpages, I am utilizing .ejs files. Upon clicking the submit button on the file upload form, Express routes me to testfile.js where I am using the Parse.File method to upload the file to the Parse database. However, I suspect there might be an issue with my function that extracts the file from the submitted form. I have attached both testfile.js and the .ejs file containing the upload form for your review. Please take a look and provide suggestions for the correct solution.
exports.xmlfile = function(req, res) {
var filecontrol = $("#myfile")[0];
var file= filecontrol.files[0];
var parseFile= new Parse.File("8706388_orig.jpg",file);
parseFile.save().then(function(){
var newobj= new Parse.Object;
newobj.set('file', parseFile);
newobj.save();
res.redirect('/administrator');
});
};
This is the upload form in the .ejs file:
<form class="form form2" id="myform" name="myform" enctype="multipart/form-data" method="post" action="/administrator">
<input type="file" id="myfile" name="myfile">
<input class="w-button upload" type="submit" value="Upload" >
</form>