PHP download size limit

Source: Internet
Author: User
Tags php download
Header (& #039; content-type: texthtml; charsetUTF-8 & #039;); $ pathPFW_VERSION_UPLOAD_PATH. & #039; & #039 ;. $ res [& #039; file_path & #039;]; header (& #039; Content-type: applicationoctet-stream & #039;); header (& #039; content-Disposition: attachment; filenam...

Header ('content-type: text/html; charset = UTF-8 ');
$ Path = PFW_VERSION_UPLOAD_PATH. '/'. $ res ['file _ path'];
Header ('content-type: application/octet-stream ');
Header ('content-Disposition: attachment; filename = "'. $ res ['file _ path'].'" ');
Header ('content-Length: '. $ res ['file _ size']);
Readfile ($ path );
The above is the php download code. All the packages to be downloaded are 10 MB or more. There is no upload problem, but only kb or less can be downloaded.
What problems may be caused?
(Server environment: linux nginx php5.5 + php-fpm)


In this way, only 32 KB is downloaded later.

Reply content:

Header ('content-type: text/html; charset = UTF-8 ');
$ Path = PFW_VERSION_UPLOAD_PATH. '/'. $ res ['file _ path'];
Header ('content-type: application/octet-stream ');
Header ('content-Disposition: attachment; filename = "'. $ res ['file _ path'].'" ');
Header ('content-Length: '. $ res ['file _ size']);
Readfile ($ path );
The above is the php download code. All the packages to be downloaded are 10 MB or more. There is no upload problem, but only kb or less can be downloaded.
What problems may be caused?
(Server environment: linux nginx php5.5 + php-fpm)


In this way, only 32 KB is downloaded later.

Switch the server environment from ubuntu to CentOS. Change the PHP FastCGI manager from Spawn to php-fpm. When downloading large files: fastcgi will be cached in the/var/lib/nginx/tmp/fastcgi temporary directory, but this directory does not have the write permission for the www-data user, resulting in downloading files only about 30 kb, the file cannot be downloaded completely. For details, refer.

Is it because of the execution time?

Why can't I direct Location to a file for PHP to read files? For authentication, referX-SendfileMechanism.

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.