django - Upload Files

django Upload Files

1, file upload forms where the need to meet two conditions

  • Submission must bepost
  • Form must provide a enctypeproperty, and the value must bemultipart/form-data
  • multipart / form-data representative of a form submission data stream in the form of

2, in the django, receiving the file object request.FILES

file = request.FILES.get("key")

file common methods are those?

  • read (): the file is read and placed in a stream, a one-time reading is completed, suitable for small pictures
  • chunks (): read the block in the manner of a document read for large files

What are common file attributes?

  • name: file name
  • size: file size
  • content_type: File Types

Guess you like

Origin www.cnblogs.com/leomessi10/p/11871708.html