On Tue, Jul 15, 2003 at 11:51:53AM -0400, Randall Perry wrote:
> -----------------------------------------------------------------------
> Got this basic code snippet from the 'Perl & LWP' book and modified it:
> -----------------------------------------------------------------------
>
> use strict;
> use warnings;
> use LWP::UserAgent;
> my $browser = LWP::UserAgent->new;
>
> my $url = 'http://www.acme.com/data.html';
you need the action URL instead, ie
my $url = "http://www.acme.com/cgi-bin/upload.cgi";
> my $response = $browser->post( $url,
> [ 'login' => 'test',
> 'password' => 'shmest',
> 'file' => ["/Users/acme/acme.zip"],
> ],
> 'Content_Type' => 'form-data',
> );
>
> print $response->content;
>
> die "$url error: ", $response->status_line
> unless $response->is_success;
> die "Weird content type at $url -- ", $response->content_type
> unless $response->content_type eq 'text/html';
>
> -----------------------------------------------------------------------
> Running the script produces the following output:
> -----------------------------------------------------------------------
>
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD>
> <TITLE>405 Method Not Allowed</TITLE>
> </HEAD><BODY>
> <H1>Method Not Allowed</H1>
> The requested method POST is not allowed for the URL /data.html.<P>
> <HR>
> <ADDRESS>Apache/1.3.27 Server at www.acme.com Port 16080</ADDRESS>
> </BODY></HTML>
> http://www.acme.com/data.html error: 405 Method Not Allowed at
> post_file_upload.pl line 20.
>
>
> -----------------------------------------------------------------------
> Here's the form the script submits to
> -----------------------------------------------------------------------
>
> <form name = "data" enctype="multipart/form-data" method="POST"
> action="http://www.acme.com/cgi-bin/upload.cgi">
> <input type="hidden" name="ac" value="upload">
> Username:<input type="text" name="login" size="10">
> Password:<input type="password" name="pass" size="10">
> Choose File:<input type="file" name="file" size="30" maxlength="80">
> <input type="submit" value="Upload File" name="submitUpload">
> </form>
>
> -----------------------------------------------------------------------
> Anyone know what's wrong?
> -----------------------------------------------------------------------
>
>
>
> --
> Randall Perry
> sysTame
>
> Xserve Web Hosting/Co-location
> Website Development/Promotion
> Mac Consulting/Sales
>
> http://www.systame.com/
>
--
"Strange women lying in ponds distributing swords is no basis for a system
of government. Supreme executive power derives from a mandate from the
masses, not from some farcical aquatic ceremony."
Dennis - Monty Python and the Holy Grail.