Access file object from ondata Handler

33 Views Asked by At

Is it possible to access the current file object of the input field in the ondata handler in order to send file-specific data as POST? I would like to send the lastModfiedDate of the uploaded file. At the moment, I send the data of all files with each request and then try to assign it via the file name:

var addedFiles = [];
[...]

ondata: (formData) => {
  for(var i = 0; i < addedFiles.length; i++) {
    formData.append('filename['+i+']', addedFiles[i].name);
    formData.append('lastModified['+i+']', addedFiles[i].lastModified);
  }
  return formData;
}

$('#myFileInput').on('FilePond:addfile', function (e) {
  addedFiles.push(e.detail.file.file);
});
0

There are 0 best solutions below