I have recently ported most of my CGI programs to mod_perl. I _need_ Apache.pm loaded, and those of you familiar with mod_perl unterstand the importance of removing redundant code. Everything was going great, until I needed to reuse some old code to accept user uploads. The only code uses CGI.pm, and I don't want to do that. My question is, how do I get at the uploaded file via an apache request object, and how is this different (internally) than with CGI.pm?
Here is the code that is not working
my %params = $r->method eq 'POST' ? $r->content : $r->args;
while ( my ( $key, $value ) = each %params ) {
if ( "some reg-exp that is true if there is an upload" ) {
print STDERR "value=$value\n";
my $tempfile = $value;
#some fiddling with the $tempfile
my $buffer;
print STDERR "tempfile=$tempfile\n";
open( *OUTFILE,">>/tmp/myb.$tempfile") || die "couldn't op
+en outfile: $!";
while ( read( $value, $buffer, 1024 ) ) {
print OUTFILE $buffer;
}
close( *OUTFILE );
}
}
and $tempfile gets created, but is empty.
I've tried perdoc Apache, and I've tried the mod_perl Guide.
Any help or references would be greatly appriciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.