hmm i dont know what kind of problems i was having earlier, but now coffee seems to have helped!!

i think part of this might have to do with getting parameter in these two ways, which just made sense when edoc showed me the line:
#normal $r from my POV sub handler { my $r=Apache::request(); %args=$r->args; my $sitename=$args{sitename}; }
or
#$apr sub handler { my $r=Apache::request(); my $apr = Apache::Request->new( $r , POST_MAX => 10 * 1024 * 1024, # in byte +s, so 10M DISABLE_UPLOADS => 0); my $sitename = $apr->param('sitename'); }
it seems obvious that $apr loads parameters in differently ? or am i mistaken/used to Apache::request as opposed to Apache::Request? here is the working code

package PP::Uploads; use Apache::Constants qw(OK); use Apache::Request; use Apache::Util qw(escape_html); use strict; sub handler { # Standard stuff, with added options... my $r = Apache::Request->new(shift, POST_MAX => 10 * 1024 * 1024, # in byte +s, so 10M DISABLE_UPLOADS => 0); my $status = $r->parse(); my $sitename = $r->param('sitename'); # Return an error if we have problems. return $status unless $status == OK; $r->send_http_header('text/html'); $r->print("<html><body>\n"); $r->print("<h1>Upload files</h1>"); # Iterate through each uploaded file. foreach my $upload ($r->upload) { my $filename = $upload->filename; my $filehandle = $upload->fh; my $size = $upload->size; $r->print("You sent me a file named $filename, $size bytes<br>"); $r->print("The first line of the file is: <br>"); my $dir="/tmp/$sitename/"; my $line; while ( <$filehandle>) { $line.=$_; } mkdir $dir; my $image=$dir.$filename; open FH ,">$image" or die $!; print FH $line; close FH; # $r->print(escape_html($line), "<br>"); } $r->print("Done......<br>"); # Output a simple form. $r->print(<<EOF); <form enctype="multipart/form-data" name="files" action="/PP/upload" + method="POST"> <input type=hidden name=sitename value=$sitename> File 1 <input type="file" name="file1"><br> File 2 <input type="file" name="file2"><br> File 3 <input type="file" name="file3"><br><br> <input type="submit" name="submit" value="Upload these files"> </form> </body></html> EOF return OK; }; 1;

In reply to Re: Re: mod_perl upload woes by drfrog
in thread mod_perl upload woes by drfrog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.