greasemonkey file upload

Programmatically Setting the Value of HTML Input File Element in Firefox

Submitted by Eus
on July 24, 2010 - 5:54am

I had a need to automatically fill the value of an HTML file upload box in Firefox. I thought Greasemonkey would just do the job. But, it was not that simple because to prevent a malicious website to upload any file in your local system without your knowledge, Firefox prevents the value of a file upload box to be set programmatically. Googling for information to do what I wanted did not return a good result other than simple information stating that it would not be possible due to the aforementioned security reason. So, I digged the source code to figure out either the way myself or better googling keywords. Finally, I came up with the right way to do what I wanted.