Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an one question about nginx upload module and file names:

2013/02/05 21:01:55 [info] 23432#0: *5 started uploading file "kvm.pdf" to "/var/www/html/0000000004" (field "file[]", content type "application/pdf"), client: 127.0.0.1, server: , request: "POST /upload/share?X-Progress-ID=0520d308f3b8c4ee5d03b20301416031 HTTP/1.1", host: "localhost", referrer: "***/upload/share?X-Progress-ID=4113dd986661cafbb8cfeede98d9dba2"
2013/02/05 21:01:55 [info] 23432#0: *5 finished uploading file "kvm.pdf" to "/var/www/html/0000000004", client: 127.0.0.1, server: , request: "POST /upload/share?X-Progress-ID=0520d308f3b8c4ee5d03b20301416031 HTTP/1.1", host: "localhost", referrer: "***/upload/share?X-Progress-ID=4113dd986661cafbb8cfeede98d9dba2"

I've uploaded file kvm.pdf but it was saved as 0000000004, which is not a good idea. Can it be changed to store files with original names?

upload_set_form_field $upload_field_name.name "$upload_file_name";
upload_set_form_field $upload_field_name.content_type "$upload_content_type";

This lines included in config but it isn't working.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You're not using the upload module correctly. From the upload module documentation:

The module parses request body storing all files being uploaded to a directory specified by upload_store directive. The files are then being stripped from body and altered request is then passed to a location specified by upload_pass directive, thus allowing arbitrary handling of uploaded files. Each of file fields are being replaced by a set of fields specified by upload_set_form_field directive. The content of each uploaded file then could be read from a file specified by $upload_tmp_path variable or the file could be simply moved to ultimate destination.

The upload module takes care of the actual upload of the file data, but then passes control to another location (which you provide) which takes care of actually processing the uploaded data. The 0000000004 file is temporary -- if you want to permanently store the uploaded files you must provide a script which moves that temporary file to its final location. You can name the file whatever you want in that script.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.4.17.1557\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Server Fault works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </noscr"], "copyright__copyright__copyright": ["of actually processing the uploaded data. The 0000000004 file is temporary -- if you want to permanently store the uploaded files you must provide a script which moves that temporary file to its final location. You can name the file whatever you want in that script.\n\nshare|improve this answer\nadd comment\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}