Thanks for the quick response (thought it was an I'm on vacation message :)

When submitting directly to the form action URL I got this output:

http://www.tasbill.com/cgi-bin/upload.cgi error: 302 Moved at
post_file_upload.pl line 20.


I stepped through the script and got this output after the 'print
$response->content;' line:

list context return from HTTP::Message::content:
0  ''

Know what this means?



> 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/
>> 

-- 
Randall Perry
sysTame

Xserve Web Hosting/Co-location
Website Development/Promotion
Mac Consulting/Sales

http://www.systame.com/


Reply via email to