How to solve the problem of file size limit in PHP? The main purpose is to modify the content in the configuration file php.ini to break through the PHP upload file size limit.
Starting from PHP 4.2.0, PHP will return a corresponding error code along with the file information array. This code can be found in the ['error'] field in the file array generated when the file is uploaded, that is, $_FILES['userfile']['error']. UPLOAD_ERR_INI_SIZE Value: 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. Its default value is 2M bytes. If the memory limit setting is activated, you may need to set memory_limit larger. Please make sure the memory_limit setting is large enough. If the max_execution_time setting is too small, the script may take longer to run than this setting. Therefore, please also ensure that max_execution_time is large enough. Note: max_execution_time only affects the running time of the script itself. Any other time spent outside of script running, such as calls to the system with function system(), use of the sleep() function, database queries, file uploads, etc., are not included in calculating the maximum time a script can run. If the value set by post_max_size is too small, larger files will not be uploaded. Therefore, please ensure that the value of post_max_size is large enough. Not validating the files you operate may mean that users can access sensitive information in other directories. Please note that CERN httpd seems to discard everything after the first space in the content-type mime header it gets from the client. Based on this, CERN httpd does not support the file upload feature. Given that there are many ways to represent file paths, we cannot ensure that file names in various foreign languages (especially those containing spaces) can be processed correctly. Excerpted from the PHP manual In fact, this thing is easy to bypass. It is safer to confirm it with JS first Restrictions on uploading files System: redhat 9+Apache 2.0 Filter+php 4.2.2 I don’t know what’s going on, but when I upload a file larger than 512k, it shows that the server cannot be found. Moreover, the server cannot be found directly without going through the upload process. apache log, error message found when uploading: [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 uploaded files, but this setting cannot be found in httpd.conf. php.ini is there, and it may have been set to 8M. In addition, there are some error messages in the error_log. I don’t know what the cause is. [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 = 2M Generally, PHP upload restrictions are set in php.ini. Please note that you need to restart after the change to take effect! Originally posted by cnteacher at 2004-5-12 05:43 PM: 524288 This setting is in another file! php.conf under /etc/httpd/conf.d/ The timeout time of 30 seconds in php.ini is too short. Change it to a longer time, such as 300 seconds. That’s it, the upload file size limit is solved in php. |