Home  >  Article  >  System Tutorial  >  Tutorial on setting up nginx+php to upload large files

Tutorial on setting up nginx+php to upload large files

王林
王林forward
2024-04-24 08:46:01975browse

Tutorial on setting up nginx+php to upload large files

To allow PHP to upload large files, you usually need to modify the configuration file php.ini, as follows
file_uploads = on ; //是否允许通过HTTP上传文件的开关,默认为ON
upload_tmp_dir ;    //文件上传到服务器临时摆放的目录
upload_max_filesize=2m; //允许上传文件大小的最大值
post_max_size = 8m ;    //指通过表单POST给PHP的所能接收的最大值,包括表单里的所有值。
max_execution_time=600; //每个PHP页面运行的最大时间值(秒),默认30秒
max_input_time = 600;   //每个PHP页面接收数据所需的最大时间,默认60秒
memory_limit = 8m ; //每个PHP页面所吃掉的最大内存,以前的机制一般默认8M,现在基本都是128m
After php is configured, nginx still cannot upload large files without corresponding configuration, and will prompt
413 Request Entity Too Large

You need to open nginx.conf and add the following parameters in the http{} configuration:

client_max_body_size 50m; //最大能上传50m大小的文件。

The above is the detailed content of Tutorial on setting up nginx+php to upload large files. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete