Nginx是没有该模块的,需要重新编译Nginx,添加nginx-upload-module模块。
下载nginx-upload-module模块:
https://github.com/fdintino/nginx-upload-module
下载完成后解压,并在重新编译Nginx时指定模块添加目录。
重新编译执行Nginx
./configure --prefix=/usr/local/nginx-1.15.9 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --add-module=/home/software/nginx-upload-module-master
make (添加模块不需要make install)
配置nginx
location /upload {
upload_pass /upload/info.php;
upload_store /tmp;
upload_limit_rate 10240k;
upload_set_form_field "${upload_field_name}_name" $file_name;
upload_set_form_field "${upload_field_name}_content_type" $nt_type;
upload_set_form_field "${upload_field_name}_path" $tmp_path;
upload_aggregate_form_field "${upload_field_name}_md5" $file_md5;
upload_aggregate_form_field "${upload_field_name}_size" $file_size;
upload_pass_form_field "^submit$|^description$";
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
文件树
localhost [/usr/local/nginx/html] 03/06/19 15:57:08
root@0
.
├── 50x.html
├── index.html
├── up.html
└── upload
├── upload.php
1 directory, 4 files
up.html文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题文档</title>
</head>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form name="upload" method="POST" enctype="multipart/form-data" action="/upload">
<input type="file" name="file">
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>
upload.php 文件
<?php
header("Content-Type:text/html; charset=utf-8");
print_r($_POST);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)