Ask a question about HTTP response message headers when uploading a file

Source: Internet
Author: User
Please consult the HTTP response message header when downloading the file.
When I was learning to use PHP for file downloads, the textbook said it needed to provide three HTTP message headers:
PHP Code
  
       Header ("Content-type:application/octet-stream");          The high-speed browser passes the file stream    header ("accept-length:2048");                             File size    header ("content-disposition:attachment; Filename=abc.txt "); Specify file name


Of these, "Content-type" and "content-disposition" two message headers, I still a little bit not understand, so I did two separate examples:

a.php:
PHP Code
  
   
  
   


b.php:
PHP Code
  
   
  
   


My question is:
1, these two pages are less a message header, why can still successfully download files?
2, although I specify the size of the file is 2048 bytes, but the real output only "123" three bytes, why can i download the file as normal?
"Accept-length" message header is can be set can not set it?

I just learned http, trouble people to answer the questions I asked, do not draw a deeper concept, because I can not understand.
Thank you very much! :)

------Solution--------------------
1, these two pages are less a message header, why can still successfully download files?

Because you do not set content-length, the output at the end of the default connection is the download content.

2, although I specify the size of the file is 2048 bytes, but the real output only "123" three bytes, why can i download the file as normal? "Accept-length" message header is can be set can not set it?

Accept-length means the length of the maximum acceptable string. So it can be set to No.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.