Opened 15 months ago

Closed 5 months ago

#20196 closed New feature (wontfix)

Better support for folder uploads

Reported by: jonash Owned by: nobody
Component: Forms Version:
Severity: Normal Keywords:
Cc: Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Feature request: Make folder uploads (<input type=file webkitdirectory>) possible in Django.

Here are some of my ideas regarding design and implementation.

Database, forms

Add a new FolderUploadField that stores the path where the folder has been uploaded to, similar to how FileUploadFields work. The object you deal with in business logic code is a Folder object, the File equivalent.


Add a QueryDict.getfolder method that returns a (Uploaded)Folder object. Note that multi-file and folder uploads are not distinguishable in POST data, so we should have some sanity checks before constructing that object. At the very least we should check that all file paths have a common folder prefix: ["foo/bar.jpg", "foo/spam.txt"] is okay while ["foo/bar.jpg", "spam/eggs.txt"] is not.

Folder object

Constructed from list of File objects, it should at least have these two methods:

  • .walk() behaves similar to os.walk but yields File objects
  • .save(dest) saves the whole folder in its original structure under dest.


Special handling is required to properly encode Folder objects in the test client.

Attachments (0)

Change History (2)

comment:1 Changed 15 months ago by aaugustin

  • Component changed from Uncategorized to Forms
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Someday/Maybe

It looks like this could live outside of core at first. I'd prefer to wait until this feature is standardized by W3C to implement it in Django.

The testing part may be tricky, but can probably be solved by subclassing the test client.

comment:2 Changed 5 months ago by aaugustin

  • Resolution set to wontfix
  • Status changed from new to closed

I still believe an external app is the way to go, at least at first. Please reopen if some code in Django needs to be changed to make this possible.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.