PHP.ini can't upload big file perfect solution
1, open the php.ini (open the way needless to say, Baidu a lot of)
2. Find Post_max_size
The form submits the maximum number, which is not a restriction on the size of an individual file to upload, but rather a restriction on the submission data for the entire form.
The default is 8M, set to the value you want, this parameter is recommended to set larger than upload_max_filesize
3. Find File Uploads
Whether to allow the switch to upload files via http, confirm file_uploads = On
4. Find Upload_tmp_dir
Files are uploaded to the server where temporary files are stored, and the system default temporary folder is used if unspecified
If the system error prompts "xxx temp directory XXX", this directory will need you to set up a valid directory, no error is not the tube
5. Find Upload_max_filesize
Allow the maximum size of the file to be uploaded, the default is 2M, set to your own needs on this parameter recommended do not exceed the post_max_size value, because it is controlled by the Post_max_size value (even if the upload_max_filesize set 1G, and Post_max_ Size is set to 2M only, files greater than 2M are still not transmitted 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 for each PHP page to run (seconds), default 30 seconds
Max_input_time = 600: The maximum time required for each PHP page to receive data, default 60 seconds
Memory_limit = 8M; maximum memory required for each PHP page, default 8M
Nginx method of uploading large files perfect solution
1.client_body_buffer_size as far as possible to set the larger point, which is based on the speed of consideration, if because the set too small, resulting in uploaded files to write the disk, the speed is too slow.
2.client_body_temp_path path to have writable permission, this is a clear error. It's good to fix it.
3.client_max_body_size set the maximum upload file, this is based on security considerations, we believe that normal users will not or basically do not upload too large files.
Can be set to client_max_body_size 100m; or set this value according to your own business.
Example
The configuration of the 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; } |
Add the Client_max_body_size field, how to restart is not possible. Later, a profile was found in the general 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 configuration file, in the allocation file to make changes. The profile 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 Http://tomcat; Client_max_body_size 1000m; } } |
With/export/servers/nginx/sbin/nginx-s reload reboot, the problem of the size of the uploaded file is solved.
Share my solution and hope to help.
If it still doesn't work out we need to see if the PHP form setup problem
This code is divided into two files, one for upload.html and one for upload.php
Upload.html
The code is as follows |
|
<form enctype= "Multipart/form-data" action= "upload.php" method= "POST" > <input type= "hidden" name= "max_file_size" value= "100000" > <input name= "UserFile" type= "File" > <input type= "Submit" value= "Upload file" > </form> |
which
Please note that
This is a tag, we want to implement file upload, must be specified as Multipart/form-data, otherwise the server will not know what to do.
It is worth noting that the hidden range of form options max_file_size in file upload.html can limit the size of the uploaded file by setting its value (values).
The value of max_file_size is only a suggestion to the browser, and it can actually be bypassed simply. So do not put a limit on the browser to that value. In fact, the maximum value of the uploaded file in the PHP settings will not expire. But it's best to add max_file_size to the form because it avoids the hassle of a user spending time waiting to upload a large file before discovering the file is 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 filename to avoid duplication $r =move_uploaded_file ($f [' Tmp_name '], $dest); chmod ($dest, 0755);//Set the properties of the uploaded file Or <?copy ($_files[myfile][tmp_name],$_files[myfile][name]);? > |
The contents of the $_files array in the example above are shown below. We assume that the File upload field name is UserFile (name can be arbitrarily named)