When calling a method within a submit button event, the code looks like this:
'submit #form': function(event, tmpl){
var files = null;
if(event.target.fileInput)
files = event.target.fileInput.files;
console.log(f);
Meteor.call('insertFiles', files, function(err){
if(err)
{
console.log(err);
}
else
{
console.log('insertFiles returned.');
Router.go('next_screen');
}
});
}
The fileInput
element is defined as:
<input type="file" name="fileInput" id="fileInput"
accept="image/jpeg, image/png, application/pdf" multiple/>
The method itself is implemented as follows:
'insertFiles'(files){
console.log(files);
//Rest of code.
}
Upon inspecting the client console log, the output for files appears as:
FileList {0: File, 1: File, length: 2}
However, inside the method, the output in the console shows:
{ '0': {}, '1': {} }
This indicates that the files are not being received correctly within the method. To resolve this issue and retrieve the file list properly, what can be done?