upload module forbidden

Francis Daly francis at daoine.org
Wed Apr 6 16:16:28 MSD 2011

On Wed, Apr 06, 2011 at 12:09:22AM -0400, vetri wrote:

Hi there,

>           what did u do to upload files ? can u give me your code ?and

It is absolutely normal cgi-type programming. There's probably a forum
for that somewhere else.

For example, the following php script called my-form-handler:

header("Content-Type: text/plain");
print("GET: "); print_r($_GET);
print("POST: "); print_r($_POST);
print("FILES: "); print_r($_FILES);

with the following nginx config snippet:

  include fastcgi.conf;
  location = /my-form-handler {
    fastcgi_pass  unix:php.sock;

will show you what you get when you GET or POST to /my-form-handler.

You can then adjust that script to do whatever you want it to do with
your own input.

> how to use stock nginx can we really upload files using stock nginx?

Yes: you use stock nginx plus your own form handler; or nginx plus upload
module plus your own form handler.

But you still have to have your own form handler.

If you use upload module, then you can use

  upload_pass /my-form-handler;

among the rest of the upload module config.

Test with something like

  curl -i -F f=@testfile -F submit=on http://localhost/my-form-handler


  curl -i -F f=@testfile -F submit=on http://localhost/upload

As it happens, the php engine does some of what the upload module does,
as regards processing the input stream and splitting it into files. So
you may see a bigger benefit to using upload module if you use a different
backend technology.

But it looks like the nginx side of the problem is resolved, unless you
have a specific follow-up question.

Good luck with it,

Francis Daly        francis at daoine.org

More information about the nginx mailing list