我在 C++ 应用程序中使用来自http://fastcgi.com/的库作为后端,使用 nginx Web 服务器作为前端。
从 HTML 表单成功发布文件,并且可以在 nginx 服务器端看到临时文件。但我不知道如何使用 fastcgi_stdio 访问多部分 POST 请求的主体。这是我的 HTML 表单。
<html>
<head>
<title>Test Server</title>
<script src="http://code.jquery.com/jquery.min.js"></script>
</head>
<body>
<form id="upload-form" method="post" target="upload_target" enctype="multipart/form-data" action="/upload">
<input name="file" id="file" size="27" type="file" /><br />
<input type="submit" name="action" value="Upload" /><br />
<iframe id="upload_target" name="upload_target" src="" style="width:100%;height:100px;border:0px solid #fff;"></iframe>
</form>
</body>
</html>
我的 nginx 配置文件:
location /upload {
# Pass altered request body to this location
upload_pass @test;
# Store files to this directory
# The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
upload_store /www/test;
# Allow uploaded files to be read only by user
upload_store_access user:rw group:r all:r;
# Set specified fields in request body
upload_set_form_field $upload_field_name.name $upload_file_name;
upload_set_form_field $upload_field_name.content_type "$upload_content_type";
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
# Inform backend about hash and size of a file
upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
upload_pass_form_field "^submit$|^description$";
upload_cleanup 400 404 499 500-505;
}
include fastcgi.conf;
# Pass altered request body to a backend
location @test {
fastcgi_pass localhost:8080
}
现在,如何在我的 fastcgi c++ 应用程序中处理/获取 POST 请求正文,以及如何在 fastcgi 应用程序端将其写入适当的文件中?
有没有更好的快速模块来实现这一点?
谢谢你。