Simply save file to folder in Django

前端 未结 4 381
野趣味
野趣味 2020-12-15 17:33

I have a piece of code which gets a file from a form via POST.

file = request.FILES[\'f\']

What would be the simplest way of saving this fi

4条回答
  •  有刺的猬
    2020-12-15 18:29

    You can use django FileField, it support specify a upload_to parameter, like this:

    data_file = models.FileField(upload_to=content_path)
    

    Where content_path can be a string or a function which returns a string.

提交回复
热议问题