Thank you very much for your reply.
This is odd - I have the exact same setup as you and this is what I did:
if ( exists $ARGS{'file'} ) {
my $upload = $r->upload('file');
....
}
But I get this error:
'Can't locate object method "upload" via package "Apache2::RequestRec"'
I even put the use Apache2::Upload in there to no avail.
In my handler.pl, I have:
use Apache2::Request;
use Apache2::Upload;
Any suggestions?
Thanks
Ogden
On Wed, 15 Nov 2006, Bill Walz wrote:
> Ogden, My setup is as follows along with the following in my httpd.conf
>
> PerlSetVar MasonArgsMethod mod_perl
> PerlOptions +GlobalRequest
>
> Apache2 2.2.3
> Perl 5.8.8
> Mod Perl2 2.0.2
> Lib APR2 2.08
> Mason 1.35
>
> Here is the init section of my component, the name of my file input
> tag is "userfile", yours was "file". This is not exactly safe as the
> file could be huge. And I could not get the size() function to work,
> when needed I use approximate value from: $ENV{CONTENT_LENGTH}
>
> <%init>
> # handle upload if requested
> if (exists $ARGS{'b_upload'}) {
>
> # create an Apache2::Upload object
> my $upload = $r->upload('userfile');
>
> if ($upload) {
> # get a filehandle for uploaded file
> my $upload_fh = $upload->fh;
>
> # binmode
> binmode $upload_fh;
>
> # suck in file
> my $file_data = join('',<$upload_fh>);
>
> ....... SNIP .......
>
> </%init>
>
> -Bill
>
> On Nov 15, 2006, at 5:26 PM, Ogden wrote:
>
> > Hi,
> >
> > I'm trying to allow files to be uploaded through Mason. My setup is as
> > follows:
> >
> > Apache 2.2.3
> > Mason 1.3.4
> > mod_apreq2 20051231/2.6.0
> > mod_perl 2.0.2
> >
> >
> > The following is my code:
> >
> > <form METHOD="POST" ENCTYPE="multipart/form-data">
> > <input type="file" name="file">
> > <input type="submit">
> > </form>
> > Mason Version: <% $HTML::Mason::VERSION %><br>
> > <%perl>
> > use Apache2::Upload;
> > my $content = '';
> >
> > my $req = Apache2::Request-> new($r);
> > my $upload = $req-> upload("file");
> > my $size = $upload-> size;
> >
> > $upload-> slurp($content);
> > </%perl>
> >
> >
> > <form METHOD="POST" ENCTYPE="multipart/form-data">
> > <input type="file" name="file">
> > <input type="submit" name="action" value="Upload" />
> > </form>
> > Mason Version: <% $HTML::Mason::VERSION %><br>
> > <%perl>
> >
> > if ( $action eq 'Upload' ) {
> >
> > use Apache2::Upload;
> > my $content = '';
> > my $req = Apache2::Request-> new($r);
> > my $upload = $req-> upload("file");
> > my $size = $upload-> size;
> > $upload-> slurp($content);
> >
> > }
> > </%perl>
> >
> > After reading online, it seems I have to add this to my httpd.conf:
> >
> > PerlSetVar MasonArgsMethod mod_perl
> >
> > Which I did. The file upload process still quits with a "End of file
> > found" error.
> >
> > How can I confirm that mod_perl is actually being set to
> > MasonArgsMethod?
> > Do I put anything special into handler.pl, which is:
> >
> > my $ah = new HTML::Mason::ApacheHandler( comp_root => '/opt/local/
> > apache2/htdocs/',
> > data_dir => '/opt/local/
> > mason-data',
> > allow_globals => ['$dbh',
> > '%session']);
> >
> > sub handler {
> > my $r = shift; # Apache request object
> > my $status;
> > return $ah->handle_request($r);
> >
> > }
> >
> > Any ideas?
> >
> > Thank you
> >
> > Ogden
> >
> >
> > ----------------------------------------------------------------------
> > ---
> > Take Surveys. Earn Cash. Influence the Future of IT
> > Join SourceForge.net's Techsay panel and you'll get the chance to
> > share your
> > opinions on IT & business topics through brief surveys - and earn cash
> > http://www.techsay.com/default.php?
> > page=join.php&p=sourceforge&CID=DEVDEV
> > _______________________________________________
> > Mason-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/mason-users
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users