943,670 Members | Top Members by Rank

Ad:
Jan 11th, 2007
0

Selecting a directory instead of file

Expand Post »
Hi experts,

Is there any way to select a directory instead of selecting a file using the html tag "input type='file'".How it can done?
If there is any solution please let me know.

Thanks,
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
techkar is offline Offline
18 posts
since Feb 2006
Jan 11th, 2007
0

Re: Selecting a directory instead of file

No. You can only select one file at a time.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jan 13th, 2007
0

Re: Selecting a directory instead of file

Click to Expand / Collapse  Quote originally posted by stymiee ...
No. You can only select one file at a time.
hi John Conde,

I got a senerio, where the end users whats to select a directory(folder) to save the file they upload.As of now ,I gave a sentence like "Select a location(folder) where u want to save the file,if the folder is empty create a dummy .txt file and select that file" .
Technically what I am doing is ,retrieving the whole path selected by the user and from that extracting only the path upto the directory(folder) not the .txt file ,finally with that path I'm concardinating with the file uploaded by the user.But this should not be the case for the user to create a dummy .txt file and selecting it instead of selecting the directory(folder).Please reply me if there is any solution for this problem?

Thanks,
Reputation Points: 10
Solved Threads: 1
Newbie Poster
techkar is offline Offline
18 posts
since Feb 2006
Jan 13th, 2007
0

Re: Selecting a directory instead of file

Click to Expand / Collapse  Quote originally posted by techkar ...
hi John Conde,

I got a senerio, where the end users whats to select a directory(folder) to save the file they upload.As of now ,I gave a sentence like "Select a location(folder) where u want to save the file,if the folder is empty create a dummy .txt file and select that file" .
Technically what I am doing is ,retrieving the whole path selected by the user and from that extracting only the path upto the directory(folder) not the .txt file ,finally with that path I'm concardinating with the file uploaded by the user.But this should not be the case for the user to create a dummy .txt file and selecting it instead of selecting the directory(folder).Please reply me if there is any solution for this problem?

Thanks,
I know what your saying. Currently there is only a file form control, not a directory form control. Solutions would be to create your own control in Java or C++ etc and have it populate your input box.
Reputation Points: 12
Solved Threads: 3
Unverified User
Godfear1 is offline Offline
46 posts
since Oct 2006
Jan 15th, 2007
0

Re: Selecting a directory instead of file

Click to Expand / Collapse  Quote originally posted by Godfear1 ...
I know what your saying. Currently there is only a file form control, not a directory form control. Solutions would be to create your own control in Java or C++ etc and have it populate your input box.
hi Godfear1,

Thanks for reply,Now it is confirmed that it cannot be done by using a HTML or javascript.Let me try out something in serverside scripting languages.

Thanks,
Reputation Points: 10
Solved Threads: 1
Newbie Poster
techkar is offline Offline
18 posts
since Feb 2006
Jan 15th, 2007
0

Re: Selecting a directory instead of file

Even using a server side sripting language, you wont be able to grab everything in a folder on a user's computer from an HTML/browser page.

Those 'input = file' forms don't give the server any filesystem access; when you press 'submit' the browser finds the file, encodes it according to the form enctype and sends it to the server as (usually) a POST request.

The only way to do it would be write a control or application FOR THE CLIENT'S browser or computer, which they would then have to accept and install.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Jan 16th, 2007
0

Re: Selecting a directory instead of file

Click to Expand / Collapse  Quote originally posted by MattEvans ...
Even using a server side sripting language, you wont be able to grab everything in a folder on a user's computer from an HTML/browser page.

Those 'input = file' forms don't give the server any filesystem access; when you press 'submit' the browser finds the file, encodes it according to the form enctype and sends it to the server as (usually) a POST request.

The only way to do it would be write a control or application FOR THE CLIENT'S browser or computer, which they would then have to accept and install.
Yes you are correct, but my requirement is ,
1) In an html form I'm getting the local hard drive location in one field
2) In other field getting the name of the file
once the users submits the form.It creates an Excel sheet from the database and store it the location given by the user, with the file name they mentioned.

So , to get the particular location of the folder I'm using the input type=file tag.But I want it like ,instead of selecting a file,want to select a folder.I had seen some desktop projects like this, for example "Install creator" when you install an application ,it will ask for the location to install the software.
But I knew that in web application there is no need for those things ,anyway I would to implement this issue in my web based desktop project.Suggest me an idea, how it can be done?

Thanks,
Reputation Points: 10
Solved Threads: 1
Newbie Poster
techkar is offline Offline
18 posts
since Feb 2006
Jan 16th, 2007
0

Re: Selecting a directory instead of file

It can't be done without custom software being installed on the user's computer.
Last edited by stymiee; Jan 16th, 2007 at 10:36 am.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Jan 16th, 2007
0

Re: Selecting a directory instead of file

When you download and install an application, the download part is deliberately in the user's control.

The install part is then able to access the filesystem, save files, etc.

Would you really want a server to be capable of installing software on your computer by the act of accessing a page on that server? Any browser or plugin that allows that kind of action is a total security risk.

(Temporarily ignoring Javascript) All you can do from a webpage is answer requests. A 'download' is just answering a request by sending the contents of a file. The browser then either asks the user where to put the file, or makes a good guess at where the file should go.

Javascript wont help you, because it's been designed deliberately to NOT allow read acces to anything on a user's computer, and to not allow write access anywhere.

Java Applets/Applications may help you out.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: probs Fire 2 and NOSCRIPT in FRAMES
Next Thread in HTML and CSS Forum Timeline: Loop thru controls in a div





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC