Fill upload field on submit action and save

I have an HTML form with an upload field that should be filled programmatically with JavaScript. I have written a function that works as desired, when I use this for test:

this.on('click', 'h2', this.fillField);

The field is filled upon the click on the header and upon manual clicking on submit button, everything is saved.

Then, I have only changed the trigger for the function

this.on('submit', 'form', this.fillField);

Upon clicking on submit, I can see how the field is filled, no errors in the console, the form is submitted, but the field is not saved. Just empty.

Why?