In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "php upload large file failure reasons and solutions", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "php upload large file failure reasons and solutions" bar!
Here are the reasons and solutions:
Case 1: the temporary directory where files are uploaded must be open and writable by the user of the PHP process owner. If not specified, PHP uses the system default value.
The upload_tmp_dir in the php.ini file is used to describe the temporary directory where the files uploaded by PHP are placed. If you want to upload files, make sure that the server does not close the temporary files and has write permission to this folder.
Case 2: the value of max_execution_time must be large enough. The variable max_execution_time sets the time, in seconds, that PHP waits for the script to finish executing before forcibly terminating the script. This variable is useful when the script enters an infinite loop state. However, this feature can also cause the operation to fail when there is a legitimate activity that takes a long time to complete, such as uploading a large file. In such cases, you must consider increasing the value of this variable to prevent PHP from closing the script when it is performing some important process, such as setting it to 90 seconds.
Max_execution_time = 90
Notice that there is also a set_time_limit function in the php function, which has the same effect as the above setting. The difference between the two is that the above is set in the php.ini file, while the set_time_limit is written in the php file. So you can also set the maximum execution time of the program in the page with set_time_limit, such as unlimited: set_time_limit (0)
Case 3: file_uploads = On the default value is on, which means that files are allowed to be uploaded through HTTP, which cannot be set to OFF.
The fourth case: upload_max_filesize = 2m sets the maximum file upload size, and the default file upload size in the php.ini configuration file is 2m. A common mistake for beginners in writing the file upload function is to specify the size of the uploaded file by setting the form area of the maximum size of the uploaded file, that is, the maximum allowed file upload size and the value of max_file_size (hidden range). In fact, others can generally bypass this value, so for security reasons, it is best to configure the upload_max_filesize option in the php.ini configuration file and set the file upload size. The default upload_max_filesize = 2m, that is, the file upload size is 2m, if you want to upload more than 8m files, such as 20m, you must set upload_max_filesize = 20m.
Case 5: the value of post_max_size must also be large enough. This variable is also a variable related to form submission, which limits the maximum amount of data that a PHP program can receive when a form submission is made by the client through the POST method. In general, set this value to be slightly larger than upload_max_filesize. For example, if you want to upload a file with 20MB, this value can be set to 21MB.
Case 6: max_input_time this variable can limit the time of receiving data by POST, GET, and PUT in seconds. If the application is running in an environment where the network is slow, you need to increase this value to increase the time it takes to receive data, such as setting this value to 90 seconds.
Max_input_time = 90
Case 7: the memory_limit must also be large enough that PHP allows you to define memory usage limits to prevent running scripts from making heavy use of system available memory. Use the memory_limit variable to specify the maximum amount of memory that a single script can use. The value of the variable memory_limit should be appropriately greater than the value of post_max_size.
Case 8: in addition, if your host is the nginx operating system, if none of the above operations work, remember to add client_max_body_size 20m in the nginx configuration file; this sentence means that the maximum allowed to upload 20MB, depending on your own situation. The location of my nginx configuration file is / usr/local/nginx/conf/nginx.conf.
Thank you for your reading, the above is the "php upload large file failure reasons and solutions" content, after the study of this article, I believe you on the php upload large file failure reasons and solutions to this problem have a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.