upload_pass_form_field
The upload_pass_form_field directive sets a form field name in the request that will be populated with a specific value from the uploaded file.
Description
The upload_pass_form_field directive is part of the NGINX upload module, which facilitates file uploads using multipart/form-data encoding. This directive specifies a field in the resulting request body that will receive the value extracted from the uploaded file. When a file is uploaded to the server, the original contents of the file are stripped from the request body, and instead, new form fields can be created to contain results derived from the uploaded files. By using this directive, users can customize the data sent in the subsequent request to a proxied server or another processing endpoint, allowing more control over what file data is transmitted and how it is represented.
To utilize this directive properly, it should be enclosed within a location block or other appropriate server/context configuration. Only one argument, which is the name of the form field to set in the request body, is required. The directive works in conjunction with others in the NGINX upload module, such as upload_set_form_field, which actually defines how to populate this form field with the file's value. This provides a flexible mechanism for handling file uploads and their associated metadata in web applications.
Config Example
location /upload {
upload_pass /process_upload;
upload_store /tmp/uploads;
upload_pass_form_field myFileField;
}Ensure the field name specified in upload_pass_form_field does not conflict with existing field names in your application.
Remember to use "upload_set_form_field" to specify how the field will be populated with the file content.
This directive is only effective if used within a proper context like location or server.