nginx上传模块nginx_upload_module使用
2024-08-09 12:53:52 219人阅读
1、安装模块
2 | wget http://www.grid.net.ru/nginx/download/nginx_upload_module-2.0.12. tar .gz |
3 | tar zxvf nginx_upload_module-2.0.12. tar .gz |
进入nginx源码目录
1 | ./configure --with-http_stub_status_module \ --add-module=/data/software/nginx_upload_module-2.0.12 |
3 | mv /usr/ local /nginx/sbin/nginx /usr/ local /nginx/sbin/nginx.bak |
4 | cp ./objs/nginx /usr/ local /nginx/sbin/nginx |
2、修改配置文件,在server中增加一下内容
02 | upload_pass /info.php; |
03 | upload_store /data/uptmp; |
04 | upload_limit_rate 1024k; |
05 | upload_set_form_field "${upload_field_name}_name" $upload_file_name; |
06 | upload_set_form_field "${upload_field_name}_content_type" $upload_content_type; |
07 | upload_set_form_field "${upload_field_name}_path" $upload_tmp_path; |
08 | upload_aggregate_form_field "${upload_field_name}_md5" $upload_file_md5; |
09 | upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size; |
10 | upload_pass_form_field "^submit$|^description$" ; |
3、前端代码
up.html
01 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
02 | < html xmlns = "http://www.w3.org/1999/xhtml" > |
07 | < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" /> |
08 | < form name = "upload" method = "POST" enctype = "multipart/form-data" action = "/upload" > |
09 | < input type = "file" name = "file" > |
11 | < input type = "submit" name = "submit" value = "Upload" > |
info.php
2 | header( "Content-Type:text/html; charset=utf-8" ); |
上传会返回如下图数据
from:http://foooy.me/nginx/158.html
nginx上传模块nginx_upload_module使用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉:
投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。