11

I want to allow users to select a local directory on a webpage (and then read all the files in the directory).

In Chrome I can add the webkitdirectory attribute to enable this functionality. According to a comment in this question and an answer to this question you should be able to do the same in firefox using mozdirectory but I am unable to get it to work.

I have tried the following in Firefox with no luck (works in Chrome):

 <input type="file" id="files" name="files[]" multiple mozdirectory="" webkitdirectory="" directory="" />

My Firefox version is 10.0.

Are there any way for a user to select a directory for input in Firefox without requiring an add-on on the client-side (like Flash)?

2
  • 4
    I think mozdirectory is a myth Commented Mar 28, 2013 at 20:37
  • Its possible now! See my answer: stackoverflow.com/a/33431704/195216 Commented Oct 30, 2015 at 8:40

2 Answers 2

9

Firefox doesn't have any API to upload directories yet (which is a shame)...not even in the nightly builds, so I don't think we will see support on this very soon. IE doesn't have one either. If you want to take advantage of this feature you must force the users to use Google Chrome (e.g. make them aware that upload directory is available only in Chrome).

A workaround would be to compress the directory in a .zip file and read it with the FileReader API. See https://stackoverflow.com/a/7842896/613453

Update
IE Edge now has support for this.
https://msdn.microsoft.com/en-us/library/mt574730(v=vs.85).aspx

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

Comments

-3

Now you can upload directory using drag and drop with chrome

read this article you will get more info

http://updates.html5rocks.com/2012/07/Drag-and-drop-a-folder-onto-Chrome-now-available

1 Comment

This does not answer the question.

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.