This is my first time attempting to create a prototype, and I'm struggling to grasp the concept of callback functions. My current project involves automating the firmware update process for our company's routers using Python, Selenium, and PhantomJS.
The javascript processes the firmware file through an onsubmit event before sending it to the target. This means I can't simply send the file with a basic request.
https://i.sstatic.net/MhMJo.png
The router script validates the form parameters and initiates the update process if they are correct.
From my developer tools window, I was able to create the firmware file as a File object stored in a variable named
data_transfer_object.dataTransfer.files
, which is a type of File Object.
My goal is to assign this File Object to the input[type="file"] form element with the name "firmware".
To do this, I need to assign
document.getElementById("firmware").files
to a FileList object
. However, I have File Objects, not items of a FileList object.
- Is there a way to write a prototype to create a FileList object and add File Objects inside?
or
- Is there an alternate method to assign my File Object to the input[type="file"] form element?
None of the following assignments seem to be working:
document.getElementById("firmware").files[0] = data_transfer_object.dataTransfer.files
document.getElementById("firmware").files.item[0]= data_transfer_object.dataTransfer.files
document.getElementById("firmware")[0] = data_transfer_object.dataTransfer.files
Thank you!