View Full Version : need help regarding getting directory path not file.

07-16-2009, 10:30 AM
hi all,

i have this web application in which the user has to browse and select a folder but not file. i used <input type="file"> , which helps in retrieving only files.

any help regarding this is greatly appreciated.


07-16-2009, 11:57 PM
If you still have this problem, maybe you could be more specific with the code that's causing the problem.

Philip M
07-17-2009, 08:57 AM
JavaScript itself has no file or directory I/O capabilities. If you're talking about an intranet (not the Internet) and you're talking about IE-only, then JavaScript has the ability to raise an ActiveX control to perform file and directory I/O. Otherwise It is not possible to select a folder as opposed to a file in that folder in any browser. This is probably a security issue.

"It is not as cold as it was yesterday, but that's probably because it's a bit warmer." - Sports commentator

rnd me
07-17-2009, 10:34 AM
the dialog box trigged by file upload inputs is native to the OS.
Windows provides several flavors of dialog boxes though its common dialog library; save as, file open, folder open, muiltiple file open, etc...

the one that IE used was of the "select a single file to open" flavor.
that makes sense given the task of an <input type="file">.

all subsequent browsers, even the ones that provide their own internal file browse dialogs, duplicate the original functionality afaik.

firefox, beginning in version 3.0 removes the file path from a <input type="file">'s value property.

others might still leave the path, and for those browsers, a user could select any file in the folder and you could figure out which folder it was in.

but in no browser can you select an empty folder, or anything other than a file.