I am looking for a way to streamline the process of uploading an image to a website through a Firefox Addon.
While I know it is possible to use createElement('canvas')
, convert Image data to base64, and XHR POST the data, I would prefer to leverage Firefox's built-in functionality if at all possible.
Typically, when a user clicks BROWSE on a site, Firefox opens a File Upload
dialogue, where they can select a file and then click OPEN.
My goal is to automate this process from the context menu so that a local file opened by the browser (such as an image) can be uploaded directly to the destination.
Is this feasible, and if so, how can it be achieved?
Further Explanation:
When selecting a file for upload in Firefox, the following data is required:
- target form
- local file location
- The action linked to the OPEN button in the FILE UPLOAD dialogue box
In the context menu scenario I envision creating:
- target form: will be predefined in the script
- local file location: the file right-clicked (i.e. gContextMenu.target.src
)
- The action: my objective is to utilize and attach 'command' to the function of the aforementioned button in Firefox
This means I want to avoid manually setting up new XMLHttpRequest()
and posting the data, opting instead to rely on Firefox's existing function.
In essence, I aim to provide the 'target form' & 'local file location' to the OPEN button function in FILE UPLOAD as if the standard process were being followed.