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-Sendfile
Mechanism.