Javascript – control the working directory for

internet explorerjavascript

Full story:
I am working on a project for my company that requires users at each of our locations to upload reports generated by a third party software. All reports generated by this software are always placed in the same directory.
Some of our less computer-literate associates, judging by past(and ongoing) experience with a similarly difficult task: downloading/Saving invoices to a particular directory off a suppliers website, will have trouble finding the correct directory to upload from.

The computers at each location are running Windows Server 2003 and currently have IE6

We would like to increase the ease of use, and compliance by setting the file inputs to point to the correct directory by default.

I initially hoped to be able to set the files directly in the input values, but this is for good reasons disabled in most browers.
Is it possible through javascript, or just in the HTML itself to control the directory that opens when the user presses the browse button?

If not, what other suggestions on how to accomplish it? Even something as simple as a way to successfully set a shortcut on the desktop that will force the browser to use the required working directory. (IE apparently ignores the 'start in' parameter of shortcuts)

Best Answer

You cannot control the contents of a file input using JavaScript for security reasons. Otherwise, you could create a hidden form with a file input field, set it to a path, and submit the form with JavaScript in order to upload the file to your server without the user knowledge.

Unfortunately, I'm not aware of a way to set the default path for the file selector. If there is one, I'm sure it will be browser-specific and can only be used by setting some option in the client side, not through HTML or JavaScript.