In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to solve php's problem of not uploading large images. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
php cannot upload large image solution: 1, open php.ini;2, find post_max_size and set it to the value you need;3, confirm "file_uploads = on";4, set a valid directory;5, set the maximum allowed upload file size.
Operating environment: Windows 7 system, PHP7.1 version, DELL G3 computer
PHP cannot upload large files Perfect solution
php.ini cannot upload large files Perfect solution
1, Open php.ini (open the way needless to say, Baidu a lot)
Find post_max_size
The maximum number of form submissions, this is not a limit on the size of a single file uploaded, but a limit on the submission data of the entire form
Default is 8m, set to the value you need. It is recommended to set this parameter larger than upload_max_filesize.
Find file uploads
Whether to allow file uploads via http switch, confirm file_uploads = on
Upload_tmp_dir
Upload files to the server where temporary files are stored. If not specified, the system default temporary folder will be used.
If the system error prompt has "xxx temporary directory xxx", then this directory needs you to set a valid directory, no error on the tube
Upload_max_filesize
The maximum file size allowed to upload, default is 2m, set to your own needs. This parameter is recommended not to exceed the post_max_size value, because it is controlled by the post_max_size value (even if upload_max_filesize is set to 1g and post_max_size is only set to 2m, files larger than 2m cannot be uploaded, because it is controlled by the post_max_size value)
6. If you want to upload files larger than 8m, you also need to set the following parameters:
Find max_execution_time = 600 ; Maximum time (seconds) per php page run, default 30 seconds
max_input_time = 600 ; Maximum time required for each php page to receive data, default 60 seconds
memory_limit = 8m ; Maximum memory required per php page, default 8m
Nginx method upload large files perfect solution
1.client_body_buffer_size Try to set it as large as possible. This is based on speed considerations. If the uploaded files are always written to disk because the setting is too small, the speed will be too slow.
2.client_body_temp_path must have writeable permissions, this is an obvious error. Just correct it.
3.client_max_body_size Sets the maximum number of files to upload. This is based on security considerations. We think that normal users will not or will not upload too large files.
This can be set to client_max_body_size 100m; or it can be set according to your business.
example
Configuration of nginx.
The code is as follows:
cd /export/servers/nginx/conf/nginx.conf, in the server section of this configuration file
location / {root html;index index.html index.htm;client_max_body_size 1000m;}
With the addition of the client_max_body_size field, no restart will work. Later, sub-configuration files were found in the total configuration file:
The code is as follows:
sendfileon;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;include domains/*;#include domains/chat.local;#include domains/chat.erp.com;#include domains/support.chat.com;#include douains/chat.com;server {listen 80;server_name localhost;
So I found the sub-configuration file and modified it in the sub-configuration file. The sub-configuration file is configured as follows:
The code is as follows:
server{listen 80;server_name chat.erp.360buy.com;# access_log /export/servers/nginx/logs/chat.erp.360buy.com;location / {proxy_pass;client_max_body_size 1000m;}}
Restart with/export/servers/nginx/sbin/nginx -s reload, and the problem of limited upload file size is solved.
Share my solution process, I hope it helps everyone.
If we still can't solve it, we need to see if it's a php form setup problem
This code is divided into two files, one upload.html and one upload.php
upload.html
The code is as follows:
Among them,
Please note
This is a label, we want to implement file upload, must specify multipart/form-data, otherwise the server will not know what to do.
Notable is the hidden range of the form option max_file_size in upload.html, which limits the size of uploaded files by setting its value(value).
The max_file_size value is just a suggestion for browsers, and in fact it can be easily bypassed. So don't expect browser restrictions on this value. In fact, the maximum upload file value in php settings does not expire. But it's best to include max_file_size in the form, because it avoids the hassle of users waiting for a large file to upload before discovering it's too big.
upload.php
The code is as follows:
$f=&$http_post_files ['myfile '];$dest_dir=' uploads';//set upload directory $dest=$dest_dir. '/'.date(ymd)._.$ f ['name '];//Set file name to date plus file name to avoid duplication $r=move_uploaded_file($f ['tmp_name'],$dest);chmod($dest, 0755);//Set attributes of uploaded file
or
The contents of the $_files array in the above example are as follows. Let's assume that the name of the file upload field is userfile(name can be arbitrary)
Thank you for reading! About "how to solve php can not upload big picture problem" this article is shared here, I hope the above content can have some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!
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.