0

I have created a chrome extension that gets my desired data-images into a external website file input (fileList) field.

enter image description here

enter image description here

How do I trigger the event of the fileList when the only listener I can see is 'Invalid' in Chrome Development tool?

enter image description here

This is the button I'm working with:

  `<input type="file" multiple="" accept="image/gif,image/jpg,image/jpeg,image/pjpeg,image/png,image/x-png" aria-label="Add photos or drag and drop" data-testid="media-upload" name="images" class="thisClassChangesAllTheTime" autocomplete="off" id="inputfile">`

Unfortunately if I try something like: $('#inputfile').click(); It will just bring up the prompt to find a new image and then my fileList images are lost once I hit add. I want to bypass the find image prompt and use the image in the fileList.

I have also tried $('#inputfile').change(); to no prevail, which I assume is because it's not a function. I've also tried the Javascript alternatives to jQuery (I know jQuery is old)

How would I find what event or handler to trigger and then how would I trigger that via code?

I'm happy with a Javascript or jQuery answer/guidance.

The site I'm trying to use this on, uses react, so I'm not sure if that effects the answer to the solution in what we target with js?

enter image description here

Any guidance/help to solve my mind numbing issue, would be warmly welcomed.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
aussiedan
  • 341
  • 1
  • 10
  • Is there an event handler on the file input? If not, then the page is relying on bubbling and you could fake an event on the immediate parent. (I don't think you'll be able to use jQuery for this because you need to generate a click event whose target is not the same as the element it's triggered on.) – Ouroborus Jul 20 '22 at 04:30
  • @Ouroborus yeah it only has 'invalid' and not a click even. So I assume clicking the file input triggers the Xt handler, is that correct? If so how do I generate a click event to target that without getting the file input image prompt box showing? If that makes sense >_< hah – aussiedan Jul 20 '22 at 05:14

0 Answers0