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,

No. You can only select one file at a time.

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,

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.

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,

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.

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,

It can't be done without custom software being installed on the user's computer.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.