0

As the title says, can AngularJs open a dialog to allow the user to select only a directory (folder), not including file name?

I am selecting a download directory, and the user doesn't get to choose file name, in case they give the wrong extension.


[Update] Urk! If I use the standard file dialog, and type a new file name, the browser errors because the file does not exist :-(

2
  • The point of the control is to upload a specific file, what would you want to do with a directory? Commented Jan 15, 2017 at 12:20
  • What does it matter? Can't we just assume that I know what I am doing? As it happens, I am selecting a download directory, and the user shouldn't get to choose file name, in case they give the wrong extension. Commented Jan 15, 2017 at 12:22

1 Answer 1

1

AngularJs of its own does not provide any feature up and above the native DOM api to be able to do this. If it is available in the DOM API, this would be possible.

To answer your question: No. There is no DOM API that allows us to prompt for a dialog box that only selects directories in the visitor's file system.

Sign up to request clarification or add additional context in comments.

2 Comments

A pity, that. I am selecting a download directory, and the user shouldn't get to choose file name, in case they give the wrong extension
You can set the header Content Disposition: attachment; filename= yourfilename.ext when you serve that file to set the filename for the user. But if they have their browser configured to prompt for a save location (which is not the default, and doing so implies some level of tech savvyness ), they will be able to change the file extension.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.