control the working directory for <input type="file">?

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.


A quick Google search resulted in JUpload -- an open source signed Java applet that seems to meet all your needs: http://jupload.sourceforge.net/

Demo site: http://jupload.sourceforge.net/advanced_js_demo.html

I'm sure there are many other such Java applets out there and it probably wouldn't be too hard to roll your own.

The only other option I can think of is a desktop uploading application.


IE uses the last folder choosen for file uploads. If you have control over the client computers, my tips is; map a drive letter to the folder where the files are located. This can easliy be done using a cmd-file put in autoload calling subst. Then instruct the users to manually enter the drive letter, as it's very short it should be possible to write a very clear and easy to follow instruction. Good luck.


Simply put, it is impossible to do any such thing. As you can see, all/most of the answers agree with this statement, and those that do not misunderstood the question. Sorry, but what you are trying to do is considered a security risk by most browsers.