views:

503

answers:

4

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)

+4  A: 

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.

Ayman Hourieh
A: 

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.

svinto
A: 

You cannot set the value of an input file, that is a security issue.

You can use an activex control, although that stuff is getting pretty out dated. There are many advanced file upload activex controls and I bet you can pick one up pretty cheap.

Registry setting for Download directory might do the trick: (even though its an upload) and you would have to figure out how to set it every time they open IE

HKCU\Software\Microsoft\Internet Explorer\DownloadDirectory
Chad Grant
A: 

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.

brianpeiris
java is a bit invasive don't ya think? There are many activex controls and flash upload controls I would choose before having to install a 100MB+ runtime that sucks native resources, etc.
Chad Grant
Flash upload controls won't cut it either, they follow the same security rules as basic HTML -- File names and extensions only.You're right about the Java footprint but I'm just as hesitant to use an ActiveX control and/or registry hacks. Call me prejudiced, I suppose, but I'd go for OS/browser independent Java over and ActiveX control running on IE any day :P
brianpeiris