$upload_file_name is null

Megha nginx-forum at nginx.us
Thu Oct 18 09:45:45 UTC 2012


I am trying to upload file from client(simple HTML multipart post request)
to my Nginx server.
I can upload the file on Nginx server successfully but  $upload_file_name is
null. I am using Nginx log mechanisam to
see the value as below:-

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"'
                      ' ** "$upload_file_name"  **';

My Nginx conf file:

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
        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_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_aggregate_form_field "$upload_field_name.size"

        upload_pass_form_field "^submit$|^description$";
        upload_cleanup 400 404 499 500-505;

HTML page:

        <title>Test Server</title>
        <script src="http://code.jquery.com/jquery.min.js"></script>
        <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>

Am I missing here something or do I need to add some extra code here to get
values of $upload_file_name, "$upload_content_type" etc ? Or do I need to
modify my client code ?

Thank you.

Posted at Nginx Forum: http://forum.nginx.org/read.php?21,231955,231955#msg-231955

Подробная информация о списке рассылки nginx-ru