Upload entire directory in django

2019-04-02 10:34发布

I'm trying to make a web interface in django for clients to upload the entire contents of a folder to my website. This will be useful for when I'm building sites for clients which have a lot of images (artists/event planners/etc). Even though getting a zip file would be easier, being able to just grab a directory would be nicer for my...erm...less technically inclined clients. So, is there anyway I can create a django form which will accept and upload all files within a directory?

I can find plenty examples on how to do single files and they seem straight forward enough but I'd really prefer something that will take a directory and grab everything within that directory.

2条回答
虎瘦雄心在
2楼-- · 2019-04-02 11:07

It sounds like your are looking for https://github.com/tstone/django-uploadify. If you need some more details, also have a look here: Uploading multiple files in Django through one form field.

And just saw, that blueimp comes with builtin Django Backend as well

However, be aware, that you need "modern" browsers for this to work :-), it will probably not be compatible down to IE 6 or 7

查看更多
Juvenile、少年°
3楼-- · 2019-04-02 11:16

Probably all decent browsers prevent arbitrary filesystem access. You can however use javascript to select all files in a directory and iterate over them creating an upload field in your multipart form for each one of them.

There are some freebies out there, e.g. http://blueimp.github.com/jQuery-File-Upload/

查看更多
登录 后发表回答