Google Answers Logo
View Question
 
Q: Directory chooser dialog in plain html or javascript (not java!) ( No Answer,   0 Comments )
Question  
Subject: Directory chooser dialog in plain html or javascript (not java!)
Category: Computers > Programming
Asked by: poplazar-ga
List Price: $2.00
Posted: 05 Jan 2003 13:22 PST
Expires: 04 Feb 2003 13:22 PST
Question ID: 137938
How does one create a directory chooser dialog in plain html or
javascript?

Clarifications:
-The correct answer would indicate how one creates a directory chooser
control in plain html or javascript which in all respects functions
similarly to the html "file upload" dialog, except that it allows
selections and uploads of directory names.
-An answer pointing to using Java or proprietary technology coding
solutions will not be considered relevant.
-An answer pointing to using "File upload" html dialog control will
not be considered relevant ("File upload" html dialog control allows
selections of files only.)

Request for Question Clarification by joseleon-ga on 06 Jan 2003 04:28 PST
Hello:
  I don't think this question can be answered, you cannot read local
user directories using javascript, this will lead to a security flaw.
Could you tell us a bit more of what you want? Maybe there is another
possible solution that fits your needs.

Regards.

Clarification of Question by poplazar-ga on 06 Jan 2003 10:14 PST
Hi,

The question could be answerable, though the answer may still turn out
be negative, but for reasons other then the ones stated below.

To clarify...

The security concern is not an issue, since the functionality in
question is a subset of the "File Upload" functionality that's part of
standard HTML 3.2 and supported by IE 4+ and Netscape 3+.

Look into "File Upload" functionality (input name="file" type="file"
in html lingo.) http://www.faqs.org/rfcs/rfc1867.html

You can see how it's implemented in browsers on any web based email
apps (e.g. yahoo or hotmail), which use it to allow the user to attach
files to their emails.  Or here is a good example implementation of
it:
http://www.cs.columbia.edu/~hgs/upload/
Note how you can browse through dirs for files on your local machine. 
Note how you can select any file and subsequently upload it to the
server.
Note how you *cannot* select a directory and just upload its name.  
That's what the question is about.  
Whence a control similar to the "File Upload" control in regards to
its ability to browse local/network disk for dirs and files, but
permissible enough to allow the user to select directories and allow
him to upload their names to the server?

I hope this clarification helps.

Thanks.

Request for Question Clarification by joseleon-ga on 06 Jan 2003 12:13 PST
Hello, poplazar:
  Let me clarify some things regarding the security issue I posted
before. By using the standard file upload dialog (and here is the
point) the developer cannot read the contents of the user hard disk,
this dialog is created "by the browser" to allow the user select a
file and the developer only knows the contents of the file once is
posted to the internet.

One thing is this:
-The developer tells the browser to allow the user select a file and
is informed about that file

And another very different is this:
-The developer read the contents of the user hard disk and shows a
dialog to allow the user select a file

The second option is not possible, there were some security flaws in
previous IE version which allowed what you want, but were security
issues, not features, I hope is more clear this time, and I'm afraid
that the answer is negative.

Regards.

Clarification of Question by poplazar-ga on 06 Jan 2003 14:37 PST
Hi,

This should be obvious from the discourse but I'll reinforce.

The question wasn't about: 
"-The developer read the contents of the user hard disk and shows a
dialog to allow the user select a file."
which seems to be what you are responding to.  
Maybe you misunderstood the question, in which case I am wondering
why.  Please elaborate, if you care.

Of course, that would be a feature of dubious justification and a
security issue which browsers don't allow.

But that's beside the point -- the question wasn't about the developer
reading the users local disk at all.
The unanswered question is still:
"How does one create a directory chooser dialog in plain html or 
javascript?"
Which means:
- "directory chooser dialog" -- a dialog through which (note!)
the-browser-user can choose and select a directory on their local disk
- "in plain html or javascript" -- an html or javascript
directive/command that will instruct the browser when rendering the
html page to render a gui control very similar to the one rendered by
<input name="file" type="file"> to allow the user to launch the
"directory chooser dialog"

Hope this helps -- cheers.

Request for Question Clarification by mrbuzz-ga on 06 Jan 2003 14:42 PST
Hi poplazar-ga,

Joseleon is correct.  You simply cannot create a directory chooser
dialog also commonly known as just "Browse Folders" (which you see
with various Windows applications) that shows a web visitor's folders
using plain html or javascript.  I understand that you don't need to
actually read their files but even so, as far as I know, such
functionality does not exist in html or javascript.

The only possible solution is using a client-side technology such as
ActiveX where the client side control displays the Browse Folders
dialog.  If this is what you are looking for, we can help you there.

Unless, I am misunderstanding your question and that you wanted a
"Browse Folders" function for directories on your web SERVER and not
the web visitor's folders.  In that case, such products are readily
available.

Good luck,
mrbuzz-ga

Request for Question Clarification by joseleon-ga on 06 Jan 2003 23:50 PST
Hello:
  Thanks, mrbuzz for your comments ;-). Poplazar, bear in mind that
the File Chooser dialog you can show to the user using HTML is not
developed in HTML or in JS, is shown by the browser. I don't know what
more to say, please, read my previous posts and think about it, I'm
not going to answer this question, I just wanted to let you know that
is not possible what you want only with HTML/JS.

Regards.

Clarification of Question by poplazar-ga on 07 Jan 2003 10:27 PST
Hi,

Thanks all for your comments.

To the mrbuzz-ga's comment:

"You simply cannot create a directory chooser
dialog also commonly known as just "Browse Folders" (which you see
with various Windows applications) that shows a web visitor's folders
using plain html or javascript."  I would say:

Check out the link I included http://www.cs.columbia.edu/~hgs/upload/
and see that indeed you can instruct the browser through html to
create a "Browse Folders" control on the rendered page.
Watch how you can browse the folders and files on your own machine. 
  
So it's not that the control itself can't be done or rendered by the
browser, it's that its default behaviour may not be customizable or
controlable through html or javascript (I don't know -- that's why I
asked the question.)

Regarding the mrbuzz-ga's comment:
"The only possible solution is using a client-side technology such as
ActiveX where the client side control displays the Browse Folders
dialog.  If this is what you are looking for, we can help you there."

The question was html or javascript on purpose.  ActiveX solutions (or
even Java for that matter to large extent) would be platform and
browser dependent.

Thanks all again for trying to help.

Request for Question Clarification by joseleon-ga on 07 Jan 2003 11:02 PST
Hello, poplazar:
 I think you are missing the point here, mrbuzz said a "Browser
Folder" dialog, not an "Open File" dialog which is completely
different. And also you cannot control a browser-created dialog using
HTML or Javascript, sorry, the answer to your question is "No, you
cannot create such thing".

Regards.

Clarification of Question by poplazar-ga on 07 Jan 2003 14:08 PST
Hi joseleon, 

Hmm, maybe it would help if you quoted the relevant paragraph where
'"Open File" dialog' was first introduced in the thread and by whom.

Again, if you go to the http://www.cs.columbia.edu/~hgs/upload/ url
and click on the "browse" button, you will see a "Choose File" dialog,
which allows one to browse through local and mounted filesystems and
choose files.
It's not an "Open File" dialog.  
It's a "Choose File" dialog.  
It allows for browsing of folders/dirs.  
Now think of the fact that directories are files.  
Now think of the fact that it might (just might) be plausible to allow
for choosing of directories in addition to files, so that the dialog
behaves as "Choose File or Directory" or some such, and where the user
would be able to select a directory in addition to just navigate
through it.

No "Open File" dialogs, or opening of files, or security risks about
programmatically reading the users disk without their permission or
(insert) any other misunderstanding you may have had in parsing the
original question.  None of those were ever part of the question and
bringing them up or commenting upon them, while entertaining, will
remain irrelevant.

Cheers.

Request for Question Clarification by mrbuzz-ga on 07 Jan 2003 19:30 PST
Hi poplazar-ga,

I think you misunderstood what I meant by "Browse Folders".  What I
meant was that the "Browse Folders" dialog is a dialog without the
option of choosing (or even seeing) files at all; only a folder.

An example of what I was referring to can be seen by going into
Internet Explorer, Tools menu, Internet Options, Settings button, then
clicking on the Move Folder button.  That Browse Folders dialog is
what I was referring to and presumed you were looking for how to
achieve that using html.  I'm saying that in html, there isn't a way
to create that Browse Folders dialog as far I know.

Let me clarify that I understand the link you were referring to about
Choosing a File.  I've used that on countless occasions on my own
webpages for uploading data.  However that dialog does not allow you
to specify a folder; only a file.

As joseleon-ga said, the Choosing a File dialog is created by Internet
Explorer.  A different dialog, although similar is created by
Netscape.  On Linux machines, Mozilla and Konquerer (both web
browsers) create their own interface for Choosing a File.  As far as I
know, none of these interfaces will let you choose only a folder and
to my knowledge in html (for which I have programmed and used for over
9 years) or javascript can accomplish choosing a folder only.

Now what I can suggest is only that you use the Choose a File dialog
and ask a user to choose any file in the folder that he/she wants to
specify then using code similar to this:

<form name="testform">
<input type=file name=fileb>
<input type=text name=folder>
<input type=button value="Get Folder"
onclick="javascript:GetFolder();">
</form>
<script language="JavaScript">
<!--
function GetFolder() {
	document.testform.folder.value=document.testform.fileb.value;
}
//-->
</script>


As can be seen above, I implemented the GetFolder function as a
button.  On your form, you would probably implement it as the form's
OnSubmit event.  Once you have the file name, you can parse out the
filename and use the folder name purely.  Unfortunately, with this
method, the user will be uploading that particular file he/she chose
and due to security reasons, you cannot change the contents of which
file the user chose or even blank/null out the file field (the one
with the Browse... button).  Also, this would not work with a folder
without any files in it.  This is not an elegant solution at all but
it would be the only way that I can see how this might work.

I hope this gives you some insight and perhaps an alternative.  If you
however, do find a function in javascript or a way in html to
accomplish selecting a folder only such as the Move Folder button I
was referring to earlier, please let me know through this page since I
would be deeply interested.

Good luck,
mrbuzz-ga

Clarification of Question by poplazar-ga on 08 Jan 2003 10:55 PST
mr-buzz, thanks for your answer. It's very informative. If I find some
way to do this (doubtfull), I'll post in on the thread.

joseleon, thanks again for helping and answering the question.

Regards.
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy