How is the ReadFile () file size in PHP set?

Source: Internet
Author: User
Tags fpm learn php php ziparchive readfile

This article and we share the main is PHP ReadFile () file size settings related content, a look at it, hope to learn PHP to help you.

Using PHP ziparchive generated compression package, small compressed package can be downloaded, today encountered more than 150M reported 404 error, the first thought is that the file size exceeds the PHP default settings, modified method has two:

Php.ini:memory_limit

Memory_limit is to set the memory limit, if the use of ReadFile () read the file will be related to this, directly modify this value after saving restart PHP-FPM can be.

Memory_limit = 128M

Last remember: Service php-fpm restart

Ini_set

PHP Ini_set is used to set the value of php.ini, when the function is executed, we directly used to modify the memory execution size, some friends use virtual space, this function is the Savior.

Ini_set (' Memory_limit ', ' 512M ');

A complete example:

Set_time_limit (0);

Ini_set (' Memory_limit ', ' 512M ');

Header ("Cache-control:public");

Header ("Content-description:file Transfer");

Header (' Content-disposition:attachment; Filename= '. basename ($zipfile));

Header ("Content-type:application/zip");

Header ("Content-transfer-encoding:binary");

Header (' Content-length: '. FileSize ($zipfile));

Ob_clean (); Flush ();

@ReadFile($zipfile);

unlink ($zipfile);

Source: Experience Box

How is the ReadFile () file size in PHP set?

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.