forward arguments in upload module
francis at daoine.org
Tue Jun 14 21:31:11 MSD 2011
On Tue, Jun 14, 2011 at 02:07:35AM -0400, vetri wrote:
it looks like your backend is still unclear about the difference between
POST data and query strings. This is not nginx-related, but more like
CGI programming (or writing a form handler).
> In the Server log i printed Field name and value .here what i got
> when i upload nginx.tar.gz
> Field Name is file1.name Field Value is
> Field Name is file1.content_type Field Value is
> Field Name is file1.path Field value
> is /home/vetriselvanm/Desktop/upload/0000000001
This means your backend will be getting the same key/value pairs.
> My backend server will parse the key value pair and it will print it.
> for example if it recieves name=run.txt
> it will print paramname ::name and paramvalue::run.txt
> after the file is uploded i am receiving notification but no
> key=value is passed to backend .
The key/value pair is passed to the backend. It is not passed like
key=value in the query string; it is instead passed like
Content-Disposition: form-data; name="key"
within the POST body.
upload_set_form_field key value;
you include in the nginx config, you will get one block like that.
> i used upload_pass_form_field directive to pass key=value to backend
> .below is the directive what i used .
> upload_pass_form_field "^submit$|^description$";
If the original POST included fields with names that match that regex
-- in this case, exactly "submit" or "description" -- in the POST body,
then they will be sent though to the backend.
> am i using the regex pattern correctly?or should i change it ,if i have
> to change? how ? give me backend handler code to parse key=value or
> getting the above key values which is working for u?
Use the following 10 lines as a test CGI script (running on a web server
which runs CGI, so not nginx) to see exactly what is sent.
echo Content-Type: text/plain
[ "$REQUEST_METHOD" = POST ] &&
[ -n "$CONTENT_LENGTH" ] &&
dd ibs=1 count=$CONTENT_LENGTH
Post to that directly (with a small, text-only file, for simplicity);
and post to that as the "upload_pass" in the nginx config. You will see
exactly what is received each time, and you will see what changes the
upload module makes.
And then you can adjust your backend code to match.
Good luck with it,
Francis Daly francis at daoine.org
More information about the nginx