1

We are building a web application to help people organize their local files; it has a text input field in HTML5/JS.

Ideal functionality: user clicks on the text box and it lets them select a file or folder on their local drive, which passes the path of said file or folder to our server.

Is there a JS API or HTML5 method to find a path to a local file and folder?

1
  • I've gotta be honest, HTML and JS is going to get you nowhere in terms of a browser-based file management system. Browser security is going to be a huge hurdle for you. You would have to combine it with another technology: Flash, Java, Silverlight, or something that can ask you to trust it; even then you're going to find your project difficult. Commented Sep 28, 2012 at 4:47

1 Answer 1

2

Due to browser security, you cannot get the file location from a FILE input. For that same reason, you will notice that FILE inputs always get reset to blank after a postback. This is because the browser will not persist or expose the file path as a security measure.

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

4 Comments

Also: the only information you can get from a file input is the file name. It doesn't expose the full path to the file.
Is there a way to get just the file or folder name? We currently are thinking about partitioning the path out separately, but it would be nice if the user could select individual files from within the path to include.
As Cory pointed out, you will have access to the filename, but that's it. You can't even get then name of the parent directory. You could possibly find a Java applet to allow for the functionality you want, but nothing native in the browser.
@RyanWheale Java applets are no longer supported in most browsers, but it is still possible to do this using the File System Access API, in browsers that support it.

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.