I have an input
of type="file"
.
How do I set it's value using just JavaScript?
I don't need to select a file from the user's computer (I know it's impossible due to security reasons, although I am the user, so if I can cheat those, I'd be ok with that too), what I need it to set the file from some string I have.
I don't wanna do the post request, I want to actually set the file in the browser DOM and then click the submit button.
Context for all the weird request:
I have to upload a "transfers" file everyday to my bank's website.
They do not have an API for that, so I'm trying to use NightmareJS to automate this action and replace me.
My problem was when it came to uploading the file.
I do have this nightmare-upload, but apparently it doesn't work when it's inside an iframe (which I managed to get into with nightmare-iframe-manager) - issue.
Final thoughts:
So that's my problem.
I'm ok generating a file at disk and then selecting that path, if that turns out to be possible.
I'm also ok sending the request directly, although when I tried, that didn't seem to work (the page didn't redirect).
So, to summarize, I need a way to reproduce a human (me) accessing my bank account (i.e., I have the login and password), and uploading a file.
I'm accepting any suggestions that work and are fairly straightforward to implement.
EDIT:
Maybe you didn't read the entire question Barmar, but this one is not a duplicate, because I was very explicit about not needing the file to come from disk! If it does come from disk, that's ok, but not mandatory (and it's actually preferred that it can be a generated file based on a string).
Finally, it is not a security issue, because I'm the one doing this, in my own computer, and, as I said before, I'm willing to accept disabling any security measures necessary. I don't plan to use this code in a website and expect it to work, I only need it to run locally for me.
Please reconsider marking this question as duplicate.