apache+php solve the problem of uploading file size limit ____php

Source: Internet
Author: User
Tags php file upload ftp client import database

In the use of PHP file upload operation, you need to know how to control the upload file size settings, and file size is subject to a variety of factors, is summarized as follows:

1, Php.ini:upload_max_filesize
The maximum size of the uploaded file. The default value is 2M.

2, Php.ini:memory_limit
This directive sets the maximum number of bytes of memory that a script can request, with a default value of 8M. If you do not need any memory restrictions, you must set it to-1. If there is not enough memory, an error may occur: Fatal error:allowed memory size of X bytes exhausted (tried to allocate Y bytes)

General Import Database, if the database is too large, it will be an error , change this can

3, Php.ini:post_max_size
Sets the maximum size allowed for post data. This setting also affects file uploads. To upload a large file, the value must be greater than upload_max_filesize.

4, php.ini:max_execution_time = 30;
Maximum execution time of each script, in seconds

5, php.ini:max_input_time = 60;
Maximum amount of time each script may spend parsing request data

6, if the use of MySQL blob for binary file storage, you need to set the my.ini:max_allowed_packet=xxm

7,httpd.conf
An option in Apache is limitrequestbody, which restricts the content of HTTP requests sent out by the user. This option can be used in. htaccess or httpd.conf, and if used within httpd.conf, it can be used in VirtualHost or directory attribute settings respectively.

The setting value of the Limitrequestbody is 0 (unrestricted) to 2147483647 (2GB).

For example, to set the upload limit to 100K in the directory d:/appserv/www, you can add the following statement to the. htaccess or httpd.conf:

Limitrequestbody 1024000000
Options followsymlinks multiviews execcgi allowoverride All order
Allow,deny
Allow from all

The Apache server receives requests from the client for lengths not exceeding limitrequestbody bytes, and then transmits them to the PHP module, and the PHP module decides whether to save it as a temporary file, set the $_files global variable, and hand it over to the script for further processing.

The last thing to note:
HTML itself can post data is also limited, can not exceed 2G.

The FTP client has a 2GB boundary limit for file offset pointers, no FTP server-side or client compiled with special compilation flag , and no support for files larger than 2GB in any fs.

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.