tags:

views:

38

answers:

2

Hi,

I'd like to upload a file from a client machine to my server. The user would have to specify the file to upload as I understand it, using a form that looks like:

<input type="file" name="datafile" size="40">

This pops up a native file picker, which is great. The problem I'm having is that it's a real pain (for most users) to go looking around their machine for the file I'm interested in. Is there a way I can initialize the file picker with a path to make it more convenient for the user? Like I know some users will be on a windows machine, so I could prepopulate the picker by already sending them to the My Documents folder for example.

I don't see how this is possible, just wondering if something like that exists,

Thank you

+3  A: 

You can't force values into a file input field. It would be a laughably big security hole if you could :-)

The picker in a browser generally remembers where a user has last browsed, which is something your site can't know anyway.

Pointy
A: 

At this point really the best you can do is set the accepted file-type(s) to narrow it down for the user.

I believe the HTML spec calls for the ability to set a default file, but (most) browsers haven't implement it because of security concerns.

It will probably be implemented some day (with a check to make sure the user confirms it), but as of now so few (if any) browsers support it I wouldn't worry about it.

MisterMister