Empty Request.FILES with Django Upload forms

后端 未结 5 690
滥情空心
滥情空心 2020-12-08 02:03

Trying to use a very simple form to upload a file into a new class instance. I am expecting to have both files in request.FILES but it\'s empty. I am on the bun

5条回答
  •  庸人自扰
    2020-12-08 02:45

    I know this is an old question, but it is the first result on google for "django request.file empty" so I would like to add a potential solution after searching for two days:

    If you submit your files through ajax, make sure to send your form via formData() instead of form.serialize()

    see also here: Django JQuery Ajax File Upload

提交回复
热议问题