0

Im 99% sure this isn't possible, but here it goes.

I run a service that allows users to store certain images on our website for organisation, and these images are uploaded to a 3rd party website by the user.

What I am trying to do is make a Chrome extension that allows the user to upload the files from our site, directly to the 3rd party site without having to download them to their computer first.

I had already implemented this in a way that mimics the 3rd party websites network request, but as they keep changing how this works, its somewhat tedious to maintain my extension.

Is it possible to mimic a file input dialog? For example, take the binary of the file, and then pass it to the website as if the file dialog "open" button was clicked?

I've looked around but haven't been able to find anything specific

K20GH
  • 6,032
  • 20
  • 78
  • 118
  • You can not do that as it would be a major security flaw. What if i set the value to `c:/super secret bank details.txt` because i knew that was on your PC. I could forcibly upload data of clients PC's. You could however emulate the POST request but not the form itself. – Deckerz Apr 16 '19 at 11:22
  • Yeah that's what I thought. I've been emulating the POST request however unfortunately it seems that whatever is triggered after the open button is pressed does not get followed up when doing it this way. There are a number of automated requests made, depending on the responses etc (Hopefully that makes sense) – K20GH Apr 16 '19 at 11:25
  • If you look at those automated requests and get their output to know what they do. You should be able to easily emulate them as well. – Deckerz Apr 16 '19 at 11:26
  • Yeah something weird happens with them, I cant see a single request anywhere that actually uploads the file, yet it happens so im a bit stumped. Is it possible to trigger the events from a file upload dialog, or still the same issue? – K20GH Apr 16 '19 at 11:38
  • It depends on how that page is reading/using the file, but generally I see no reason why you can't override the input element's `files` property via Object.defineProperty inside a [page-level script](https://stackoverflow.com/a/9517879). – wOxxOm Apr 16 '19 at 11:44

0 Answers0