aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Selecting a directory instead a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Selecting a directory instead a file" Watch "Selecting a directory instead a file" New topic
Author

Selecting a directory instead a file

Anutosh Swamy
Ranch Hand

Joined: Sep 20, 2007
Posts: 30

Hi,

We all know to uplaod a file we use the input element of HTML with the type attribute set to "file" and we have to select a file, but I want to select just the directory (may be empty directoy) as a path to send it to the server.

Can any one help me to achieve this in HTML

I don't want the user to select a dummy file from the directory (chosen one) and to do some server side processing to remove the file and retrieve the path.

Thanks in advance.


K. Anutosh<br /> <br />SCJP 1.4<br />SCWCD 1.4<br />OCA (Paper I)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Anutosh,
You mean you want send a String containing the name of the path? How about providing an input element where the user can type it in?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Anutosh Swamy
Ranch Hand

Joined: Sep 20, 2007
Posts: 30

Hi Jeanne,

That's true I can provide an input text where the user can type the path, if the path is small that is fine but what if the path is too long (the desired location for the user to save a file) than it will not be a user friendly GUI so I need to make the user choose it dynamically like the way we choose the path to save a newly created notepad or a MS-Word file, like this.

Any suggestions?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The input file control only allows you to select a file. Also most browsers will not send up the file path with that control either.

Eric
Anutosh Swamy
Ranch Hand

Joined: Sep 20, 2007
Posts: 30

Is there any way at all so that I can achive what I want to have on my web page?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

No. not with HTML.

Maybe with an applet? ActiveX control (shudder)?
[ September 18, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30537
    
150

Originally posted by Anutosh Swamy:
Any suggestions?

A prompt to suggesting copy/pasting the path in?

Out of curiosity, what are you doing with the path later? You can't read from the directory without informing the user anyway. Which implies it is just text in some forum.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Selecting a directory instead a file