0
  1. When I upload a file,How a browser get the size of file ,and cal the sum size (Content-length),and make sure it is accurate.
  2. Nginx can limit file size ,for example 1M, and what exactly include in 1M,HTTP all byte? all info in one form ? Or max file in one form (for example ,a form include 3 text type and one file type )? and is Nginx judging by Content-length or file's attribute ?

  3. How I limit file's size by suffix,for example , JPG under 5M , MP4 under 20M ,ZIP under 100M

Xiao Zhen
  • 3
  • 5

1 Answers1

0
  1. When I upload a file,How a browser get the size of file ,and cal the sum size (Content-length),and make sure it is accurate.

This information comes from the OS, the file system. The browser doesn't really verify that it's accurate, but if the underlying file system fails, then the HTTP request is likely going to fail as well.

  1. Nginx can limit file size ,for example 1M, and what exactly include in 1M,HTTP all byte? all info in one form ? Or max file in one form (for example ,a form include 3 text type and one file type )? and is Nginx judging by Content-length or file's attribute ?

Multi-part request bodies have Content-Length headers which add all of the content together. Nginx doesn't care that it's multi-part, if you're limiting based on Content-Length.

How I limit file's size by suffix

Off the top of my head I'm not sure how to do this, but I'm just cautioning to note that you don't really know what's in that file, especially based on its name/suffix. The filename should be considered a hint of type only. The Content-Type header should be a bit of a stronger hint, but still not a guarantee.

Brad
  • 159,648
  • 54
  • 349
  • 530