When we use php to download a file, you will find that the file to be downloaded is large, but the developer does not use Accept-Length to obtain the downloaded file size, next let's take a look at the example of how to get the size of the downloaded file using Accept-Length. When we use php to download a file, you will find that the downloaded file is too large to be known, the developer does not use Accept-Length to obtain the downloaded file size. Let's take a look at the example of Accept-Length to obtain the downloaded file size.
Script ec (2); script
When downloading files in php, add the following header information:
Header ("Content-type: application/octet-stream ");
Header ("Accept-Ranges: bytes ");
Header ("Accept-Length:". $ fileSize );
Header ("Content-Disposition: attachment; filename =". $ fileName );
I have added header ("Accept-Length :". $ fileSize); in this case, the size of the downloaded file cannot be obtained. Although it does not affect the normal functions, I have to find out whether it is perfect.
Check the manual, search for information, and finally find the header ("Accept-Length: ***"). This is actually misleading. I really don't understand why Accept-Length is the same on the Internet. The correct one should be the header ("Content-Length: *** "); After modification, it is correct, such as the effect.
After you change Accept-Length to Content-Length, you can identify the size of the downloaded file.