Restrictions on the size of uploaded php files

Source: Internet
Author: User
Restrictions on the size of uploaded php files
How can I solve the limit on the size of specialized files in php? The main purpose is to modify the content in the configuration file php. ini to break through the php file upload size limit.

Starting from PHP 4.2.0, PHP returns a corresponding error code along with the array of file information. This code can be found in the ['error'] field of the file array generated during file upload, that is, $ _ FILES ['userfile'] ['error']. UPLOAD_ERR_INI_SIZE: 1; the uploaded file exceeds the limit of the upload_max_filesize option in php. ini. UPLOAD_ERR_FORM_SIZE value: 2; the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.

Notes

The value set for MAX_FILE_SIZE cannot be greater than the value set by the upload_max_filesize option in the ini setting. The default value is 2 MB.

If the memory limit setting is activated, you may need to set more memory_limit values. make sure that the memory_limit setting is large enough.

If the value of max_execution_time is too small, the script running time may exceed this setting. Therefore, make sure that max_execution_time is large enough.

Note: max_execution_time only affects the running time of the script. Any other time spent outside script running, such as using the system () function to call the system, using the sleep () function, database query, and file upload, this parameter is not included in the maximum time for computing scripts to run.

If the value set by post_max_size is too small, a large file cannot be uploaded. Therefore, make sure that the value of post_max_size is large enough.

Files that you do not operate on are not efficient, which may mean that users can access sensitive information in other directories.

Note that CERN httpd seems to discard the content after the first space in the content-type mime header information obtained from the client. Based on this, CERN httpd does not support the file upload feature.

Since there are many file path representation methods, we cannot ensure that the file names (especially those containing spaces) in various foreign languages can be correctly processed.

From PHP Manual

In fact, this is easy to bypass. first use JS to check if it is more secure.

Restrictions on file uploading

System:

Redhat 9 + Apache 2.0 Filter + php 4.2.2

I don't know what is going on. when uploading a file larger than k, the server cannot be found. In addition, the server cannot be found directly without the upload process.

Apache logs: [Wed May 12 17:05:10 2004] [error] [client 10.133.9.4] Requested content-length of 2025891 is larger than the configured limit of 524288

It should be a restriction on file uploading, but this setting cannot be found in httpd. conf.

In php. ini, all of them can be set to 8 MB.

In addition, the error message in error_log does not know the cause. [Wed May 12 17:04:58 2004] [notice] Digest: generating secret for digest authentication... [Wed May 12 17:04:58 2004] [notice] Digest: done [Wed May 12 17:04:59 2004] [info] (32) Broken pipe: core_output_filter: writing data to the network [Wed May 12 17:04:59 2004] [notice] Apache/2.0.40 (Red Hat Linux) configured -- resuming normal operations

; Maximum allowed size for uploaded files. upload_max_filesize = 2 M

The restrictions on PHP Upload are generally set in php. ini. Note that the modification will take effect only after it is restarted! Originally posted by cnteacher at: 524288 this setting is in another file! In php. confphp. ini under/etc/httpd/conf. d/, the timeout time is too short, for example, 300 seconds.

That's all. in php, the file size limit is fixed.

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.