DoubleLi

qq: 517712484 wx: ldbgliet

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  4737 随笔 :: 2 文章 :: 542 评论 :: 1615万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

1、安装模块

 

1 cd /data/software
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
2 make#新增模块,不用make install
3 mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
4 cp ./objs/nginx /usr/local/nginx/sbin/nginx

 

2、修改配置文件,在server中增加一下内容

 

01 location /upload {
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;#md5
09     upload_aggregate_form_field "${upload_field_name}_size" $upload_file_size;#文件大小
10     upload_pass_form_field "^submit$|^description$";
11     #如果希望把所有的表单字段都传给后端可以用upload_pass_form_field "^.*$";
12 }

 

 

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">
03 <head>
04 <title>无标题文档</title>
05 </head>
06 <body>
07 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
08 <form name="upload" method="POST" enctype="multipart/form-data" action="/upload"><!--提交到上面的/upload-->
09 <input type="file" name="file">
10  
11 <input type="submit" name="submit" value="Upload">
12 </form>
13 </body>
14 </html>

info.php

1 <?php
2     header("Content-Type:text/html; charset=utf-8");
3     print_r($_POST);

上传会返回如下图数据

点击查看原图

 

from:http://foooy.me/nginx/158.html

posted on   DoubleLi  阅读(11906)  评论(1编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2013-12-23 为什么类的定义中不能包含其自身类型,但是能包含其自身的指针或引用类型
2013-12-23 C++模板使用介绍
2013-12-23 C/C++中几种经典的垃圾回收算法
2013-12-23 c/c++字符串处理大集合
2013-12-23 Windows平台上C++开发内存泄漏检查方法
2013-12-23 [GUI]界面开发类库
2013-12-23 正确使用STL-MAP中Erase函数
点击右上角即可分享
微信分享提示