6

Is there a simple way to allow the user to select a folder from a Django form? I want to use the same widget as for a FileField, but only allow the user to select a folder so I can process all the files in that folder.

Thanks.

Jeff Wilson
  • 331
  • 3
  • 11
  • 2
    Maybe this will help you: http://stackoverflow.com/questions/5826286/how-do-i-use-google-chrome-11s-upload-folder-feature-in-my-own-code Casual HTML forms enable uploading only files – Krzysztof Rosiński Apr 12 '12 at 15:17

2 Answers2

4

It is impossible, you will never receive a directory name back from the type="file" input button

Sholomitcky
  • 397
  • 2
  • 5
2

In some cases you can use built in FilePathField with allow_files=False, allow_folders=True

FilePathField, Django's model field reference

Raffi
  • 3,068
  • 31
  • 33
Mark Mishyn
  • 3,921
  • 2
  • 28
  • 30