philou has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I need to upload files to my server (Apache+mod_perl), and am looking for a mod_perl method to handle multipart/form data within my perl handler.
I would prefer not to use the upload methods of CGI, and use some mod_perl specific methods for that task, but I have not been able to find out some appropriate way to do that (apart from reading directly from the socket).
Does anybody has some tips about that ?
Thanks

philou

Replies are listed 'Best First'.
Re: multipart/form under mod_perl
by gellyfish (Monsignor) on Feb 04, 2002 at 09:59 UTC

    I would recommend that you take a look at the Apache::Request module - it has a similar interface to that of the CGI module but works directly with the Apache API.

    You will get some code like this :

    use Apache::Request; sub handler { my ( $request ) = @_; my $apr = Apache::Request->new($request); my $upload = $apr->upload; my $fh = $upload->fh; while(<$fh>) { # do something with file contents } }

    /J\

      Thanks man,
      I thought the Apache::Request was bundled with mod_perl, but the fact is that I was actually using the basic request object provided by mod_perl.
      That Apache::Request seems to have all the features I have ever dreamed of (some of them I had to write them by myself).
      philou