From 442bc1746df2a9e654d1031f949826d10bd196b9 Mon Sep 17 00:00:00 2001 From: wosch Date: Thu, 16 Apr 2009 18:09:44 +0000 Subject: [PATCH] Fix upload function in Apache2.x, the bug is descripted in http://www.mail-archive.com/mason-users@lists.sourceforge.net/msg00744.html --- web/conf/apache2.0/cfspy.conf | 5 ++++- web/htdocs/details/upload.mc | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/web/conf/apache2.0/cfspy.conf b/web/conf/apache2.0/cfspy.conf index 5ac65cc..922095c 100644 --- a/web/conf/apache2.0/cfspy.conf +++ b/web/conf/apache2.0/cfspy.conf @@ -1,4 +1,4 @@ -# $Id: cfspy.conf,v 1.2 2009-04-15 18:23:02 wosch Exp $ +# $Id: cfspy.conf,v 1.3 2009-04-16 18:09:44 wosch Exp $ # # Sample configuration for running an IRSpy web-site under Apache 2.x. # @@ -27,6 +27,9 @@ SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler + + PerlSetVar MasonArgsMethod mod_perl + PerlAddVar MasonCompRoot "private => /home/wosch/indexdata/irspy/web/htdocs" PerlSetVar MasonDataDir /home/wosch/indexdata/irspy/web/data PerlSetVar IRSpyLibDir /home/wosch/indexdata/irspy/lib diff --git a/web/htdocs/details/upload.mc b/web/htdocs/details/upload.mc index 6497266..5a5aab3 100644 --- a/web/htdocs/details/upload.mc +++ b/web/htdocs/details/upload.mc @@ -1,4 +1,4 @@ -%# $Id: upload.mc,v 1.2 2007-07-17 14:31:54 mike Exp $ +%# $Id: upload.mc,v 1.3 2009-04-16 18:09:44 wosch Exp $ <%args> $filename => undef @@ -23,7 +23,23 @@ $filename => undef % return; % } <%perl> -my $fin = $r->upload()->fh(); + +my $fin; + +# Apache2.0 +if ($r->isa('Apache2::RequestRec')) { + require Apache2::Request; + require Apache2::Upload; + my $req = new Apache2::Request($r); + my $upload = $req->upload('filename'); + $fin = $upload->fh(); +} + +# Apache 1.3 +else { + $fin = $r->upload()->fh(); +} + if (!defined $fin) { $m->comp("/details/error.mc", msg => "Upload cancelled"); return; -- 1.7.10.4