设置文件上传限制(解除限制)

来源:互联网 发布:linux syslink命令 编辑:程序博客网 时间:2024/05/16 10:16
1.nginx
http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 10m;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

2.php.ini
file_uploads = On ;打开文件上传选项 upload_max_filesize = 20M ;上传文件上限 post_max_size = 20M ;post上限 ;还需要根据实际情况调整下面的选项max_execution_time = 180 ;脚本最大执行时间(秒) ,过短会导致文件还没上传完脚本就停止了。max_input_time = 180 ;请求的最大传输时间,过短会导致文件还没上传完传输就停止了。memory_limit = 128M ;内存上限
3.使用uploadfy.js(前端上传插件),改js上传限制
新增配置'fileSizeLimit':'8Mb'
4.如果以上举措做完后,能上传小图而不能上传小图,那么考虑php的配置memory_limit
尝试将这个配置项加大,在程序中加入以下代码
//设置memory_limit的值
ini_set('memory_limit','1024M');
//设置最大文件上传大小
ini_set('upload_max_filesize','8M');
//去除对响应时间限制,其中参数单位second(s)
set_time_limit(0);

0 0
原创粉丝点击