I am developing extension that automatically takes information from the website and opens up another website with a form and fills it with information from the original website. It works flawlessly so far but I would also like to automatically upload images from the original website to the website that has the form.
In the website that has the form there is this HTML element:
<div id="input_area">
<input type="file" accept="image/*" name="image" size="20" id="image"
onchange="blocket.apps.newad.click_extra_images(this);" style="left: -154px; top: 16px;">
</div>
On click it triggers file selector where you can choose the image file. I was planning to skip this whole file selector thing and try to upload the image from URL instead, since images can be found as URLs from the original website very easily. I am trying to avoid privacy and security issues too by uploading image straight from URL instead of users machine.
Is this possible somehow? The page that contains the form is https://www2.tori.fi/ai/form/1?ca=16. Just select the first option in the first page (Under KOKO TORI) to get to the form. There you should find the element.
https://imgur.com/a/jyb4nBE <- picture of the element where uploading happens.
Thanks for your knowledge and effort! <3
Edits:
I managed to edit the input type to "hidden" and change value for the input before uploading (leading to error). Uploading can manually be triggered using:
var event = new Event('change');
document.getElementById("image").dispatchEvent(event);
However I can't find a way to attach URL to be uploaded. I also read about "blob". Blob is apparently way to fetch data from a URL. However I have no clue how to attach blob (or the file) to that input. I also tried to but the URL as a value for uploading but it lead to error in page.