I am trying to upload an image to an input[type='file'] of another page.
Here is what I have so far:
const dT = new ClipboardEvent('').clipboardData || new DataTransfer();
dT.items.add(new File(result.products[pointer][3], 'product_image.png'));
document.querySelector('input[class="mkhogb32"]').files = dT.files;
console.log(dT);
console.log(document.querySelector('input[class="mkhogb32"]').files);
The code goes through and creates a file and adds it to the inputs files, however, the image never actually gets uploaded to the page:
The image above shows the files of the input after my function ran, showing the function went through. However, on this particular page, when an image is uploaded the traditional way off picking a file off your desktop or drag and drop it changes the css, as it displays the image.
How can I get my injected file to trigger that same reaction?
The result.products[pointer][3] refers to an image src scraped from a previous page, how can I make the injected file contain this image?
