httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith C. Perry" <netad...@vcsn.com>
Subject Re: Problem use Apache::Upload
Date Fri, 30 Jul 2004 16:20:34 GMT
Quoting Markus Wichitill <mawic@gmx.de>:

> Keith C. Perry wrote:
> > I thought that might had been it but I tried a couple of things while I
> was
> > waiting.  First here is the form:
> > 
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.or
> > g/TR/html4/loose.dtd">
> > <html>
> > <head>
> > <title>File Upload</title>
> > </head>
> > <body>
> > <form name="uploadform" action="upload.mpl?1" method="post"
> enctype="multipart/f
> > orm-data"><br>
> > <input name="sentfile" type="file">
> > <input value="Send File" type="submit">
> > </form>
> > </body>
> > </html>
> > 
> > Now, I tried...
> > 
> > my $upload = $req->upload('sentfile');
> > my $fname  = $upload->filename('origname');
> > 
> > I get this error...
> > 
> > [Fri Jul 30 09:40:12 2004] [error] Can't call method "filename" on an
> undefined
> > value at /www/local/upload.mpl line 18.\n
> 
> Aside from the 'origname' which shouldn't be there, this is how it should 
> work. I can't tell from the example why apreq doesn't see the uploaded file 
> and returns undef.
> 
> You could try adding $req->parse() before accessing the uploads. It's not 
> really documented anymore, but seems to be still necessary for big uploads. 
> I'm not sure if the API is still in flux, if only the docs are unfinished, 
> or if this is a bug.

Well good news, the $req->parse in my case seem to be needed.  Here is what I
was finally able to get going...

my $r=Apache->request;
my $req = Apache::Request->new($r, TEMP_DIR => "/www/tmp");
my $upload = $req->upload('sentfile');
my $fname;

if ($upload) {
 $req->parse;
 $fname  = $upload->filename();
}

$r->content_type('text/html');
$r->send_http_header;

if ( $fname && $fname ne "" ) {
 $r->print("Thank you for uploading <b>$fname</b><br>\n");
 $upload->link("/www/tmp/$fname");
 exit;
}


Now, I just have to move this back to my production server  :)

> > BTW, you used curly braces in your example to me but I'm assuming that was
> a
> > typo.  :)  For my own sanity I tried
> > 
> > my $upload = $req->upload{'sentfile'};
> > 
> > and it does give me a syntax error.
> 
> I didn't write $req->upload{'sentfile'}, I wrote $table->{'sentfile'}, which
> 
> uses the tied hash interface of the table class.
> 

Oh, my bad for over looking that.  Thanks for all your help.

-- 
Keith C. Perry, MS E.E.
Director of Networks & Applications
VCSN, Inc.
http://vcsn.com
 
____________________________________
This email account is being host by:
VCSN, Inc : http://vcsn.com

Mime
View raw message