In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to solve the problem that php can only upload files within 1k". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problem that php can only upload files within 1k".
Php can only upload files within 1k: 1, find and open the php.ini configuration file; 2, modify the values of "client_max_body_size" and "upload_max_filesize" and "post_max_size".
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
What if php can only upload files within 1k?
Solve the problem of PHP file upload restrictions:
Uploading large PHP files takes up a lot of resources, so you need to limit the upload size. Here are three related parameters:
Client_max_body_sizeupload_max_filesizepost_max_size
Three error messages corresponding to the above:
Warning: POST Content-Length of 9663102 bytes exceeds the limit of 8388608 bytes in Unknown on line 0 $_ FILES ['file'] [' error'] = = 1nginx error: 413 Request Entiry Too Large
Client_max_body_size is used to set the maximum size of the client Request body (request body). The file to be uploaded is in the body body, so this parameter can be indirectly regarded as a limit on the size of the file to be uploaded.
The nginx server determines the size of the body body through the Content-Length of the request header. Exceeding the upper limit of the setting returns the error code 413 Request Entity Too Large. Setting this parameter to 0 removes the length limit.
Syntax: client_max_body_size size;Default: client_max_body_size 1m political context: http, server, location
Client_max_body_size can be set in http, server, and location blocks, so we can increase the size of the upload package for the domain name or even a request address.
Php error:
Warning: POST Content-Length of 9663102 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
At this point, the size of the uploaded file is larger than post_max_size.
Php has no warning but cannot get the uploaded file
At this point, $_ FILES ['file'] [' error'] = = 1. The error is that the size of the uploaded file is smaller than post_max_size but larger than upload_max_filesize.
Knowledge points open and expand:
Solution to the problem of upload size limit of PHP and Nginx files
For some websites of nginx+php, the size of uploaded files will be limited in many aspects, one is the limitation of nginx itself, which limits the size of files uploaded by the client, and the other is the default settings of multiple places in php.ini files.
Therefore, in order to solve the problem of uploading file size limit, many changes must be made. A few places are sorted out below.
1. Modify the / usr/local/nginx/conf/nginx.conf file, look for client_max_body_size and set the following value to the value you want to set. For example:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1 root 9000 # location ~\. Php$ {root / home/www/htdocs; fastcgi_pass 127.0.0.1 php$ 9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / home/www/htdocs$fastcgi_script_name; include fastcgi_params; client_max_body_size 35m # set the file size uploaded by the client to 35m client_body_temp_path / home/www/nginx_temp; # set the temporary directory}
Appendix: Nginx has a Upload component:
Upload rate, upload Body size, that is, may be larger when uploading files?
Client_max_body_size 1024Mupload_limit_rate 158k
As follows:
Location / upload {upload_pass / up.php; upload_cleanup 400 404 499 500-505; # upload_store / data/app/test.local/upload_tmp; upload_store / tmp; upload_store_access user:r; client_max_body_size 1024M; upload_limit_rate 158k; upload_set_form_field "${upload_field_name} _ name" $upload_file_name Upload_set_form_field "${upload_field_name} _ content_type" $upload_content_type; upload_set_form_field "${upload_field_name} _ path" $upload_tmp_path; upload_aggregate_form_field "${upload_field_name} _ md5" $upload_file_md5; upload_aggregate_form_field "${upload_field_name} _ size" $upload_file_size; upload_pass_form_field "^. * $" # upload_pass_form_field "^ pid$ | ^ tags $| ^ roomyid $| ^ title $| ^ UserID $| ^ user _ id$ | ^ is _ original$ | ^ clients _ file_name$ | ^ clients _ file_content_type$ | ^ tags _ file_path$ | ^ certificates _ file_md5 $| ^ tags _ file_size$";}
2. Modify php.ini
Upload_max_filesize = 8m post_max_size = 10m memory_limit = 20m max_execution_time=300 file_uploads = On # allows HTTP file upload by default, this option cannot be set to OFF. Upload_tmp_dir = / tmp/www
When uploading large files, you will feel that the upload speed is slow. When a certain amount of time is exceeded, an error will be reported that the script will be executed for more than 30 seconds. This is because there is something wrong with the max_execution_time configuration option in the php.ini configuration file, which indicates the maximum allowed execution time of each script (seconds), and 0 means there is no limit. You can adjust the value of max_execution_time appropriately, and it is not recommended to set it to 0.
Thank you for reading, the above is the content of "how to solve the problem that php can only upload files within 1k". After the study of this article, I believe you have a deeper understanding of how to solve the problem that php can only upload files within 1k, and the specific use needs to be verified in practice. 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.