Php image Upload 500InternalServerError when writing php simple upload image, found K image upload times Internal Server Error, check upload_max_filesize, and other configuration items post_max_size, max_input_time, memory_limit, and max_execution_time are all correct. then, check the error log mod_fcgid: HTTP request length 138296 (so far) exceeds MaxRequestLen (131072.
It turns out that the setting problem in fastcgi mode is because the HTTP request length (138296) is too long and exceeds the current 131072 Max request length. After reading the fcgid configuration file, we found that the MaxRequestLen parameter has not been configured. It seems that the 131072 configuration is the default one. So add this configuration in the configuration file of fcgid, 15728640 is 15 M, because my php. the maximum POST length set in ini is 15 M, so set them to the same length: MaxRequestLen 15728640
# MaxRequestLen 15728640
AddHandler fcgid-script. fcgi. php
# Where to look for the php. ini file?
FcgidInitialEnv PHPRC "e:/wamp/bin/apache/apache2.3.14/bin"
# Set PHP_FCGI_MAX_REQUESTS to greater than or equal to FcgidMaxRequestsPerProcess
# To prevent php-cgi process from exiting before all requests completed
FcgidInitialEnv PHP_FCGI_MAX_REQUESTS 1000
# Maximum requests a process shoshould handle before it is terminated
FcgidMaxRequestsPerProcess 1000
# Maximum number of PHP processes
FcgidMaxProcesses 15
# Number of seconds of idle time before a php-cgi process is terminated
FcgidIOTimeout 120
FcgidIdleTimeout 120
# Path to php-cgi
FcgidWrapper "e:/wamp/bin/php/php5.4/php-cgi.exe". php
# Define the MIME-Type for ". php" files
AddType application/x-httpd-php. php
"MaxRequestLen"That is, the maximum file length accepted by http is uploaded in fastcgi mode.
Problem solving
Note:
PHP's default upload limit is 2 MB. to upload files that exceed this setting, you need to adjust some parameters such as PHP and apache. Next, we will briefly introduce some parameters involved in php file upload:
File_uploads
: Whether to allow file upload over HTTP. the default value is ON.
Upload_tmp_dir
: Upload_tmp_dir indicates the temporary directory where PHP files are uploaded. to upload files, make sure the server does not have the permission to close the temporary files and write the files to the folder. if not specified, PHP uses the default value.
Upload_max_filesize
: Maximum file size that can be uploaded. the default value is 2 MB.
Post_max_size
: Controls the maximum data size that PHP can receive in a form submission using the POST method. If you want to use the php file upload function, you need to change this value to a value greater than upload_max_filesize.
Max_input_time
: The time for receiving data through POST, GET, and PUT is limited in seconds. If the application's running environment is on a low-speed link, you need to add this value to adapt to the more time required to receive data.
Memory_limit
: To avoid a large amount of memory available for running scripts, PHP allows you to define the memory usage limit. The memory_limit variable is used to specify the maximum memory capacity variable memory_limit that a single script program can use. The value of memory_limit should be greater than the value of post_max_size.
Max_execution_time
: Max_execution_time sets the time for PHP to wait for the script to be executed before the script is forcibly terminated. The time is calculated in seconds. This variable is useful when the script enters an infinite loop state. However, when there is a legal activity that takes a long time to complete (such as uploading large files), this function will also cause operation failure. In this case, you must consider increasing the value of this variable to avoid PHP closing the script when the script is executing an important process.
For linux hosts, the php. conf file may exist under/etc/httpd/conf. d/access. conf/. This file may solve the file size restrictions of some systems.