in reply to Re^4: how to upload a file to a secured website?
in thread how to upload a file to a secured website?

LWP::UserAgent has redirect enabled only for methods GET and HEAD by default. Since the form's submit method is POST, the redirected responses won't be followed. Add POST to the list of redirected methods with
$ua->requests_redirectable ( ['GET', 'HEAD', 'POST'] )
So I wouldn't separate the login_url from the upload_url..... let lwp redirect it automatically, the upload cgi script probably checks if you were redirected properly. Also see if you can get some info from the server logs.
#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common qw(POST); my $login_url = 'https://mysite.com/login.do '; my $https_user = 'ABC'; my $https_pass = 'ABC'; my $file = 'File_2007_10_15_14_21_02.csv'; &postHTTPS(); sub postHTTPS { my $ua = new LWP::UserAgent(keep_alive=>1); $ua->proxy(https => 'http://ourproxyserver'); my $request = new HTTP::Request ("GET" => $login_url ); $request->authorization_basic($https_user, $https_pass); #$ua->protocols_allowed( [ 'https'] ); $ua->cookie_jar(HTTP::Cookies->new(file =>".cookies.txt",autos +ave => 1)); $ua->requests_redirectable ( ['GET', 'HEAD', 'POST'] ) # $request->proxy_authorization_basic($https_user, $https_pass); #setup request print "before posting\n"; my $req=POST ($login_url, Content_Type => 'multipart/form-data', Content_Type => [ submit => 1, Content => [ $file ] ]); print "after posting\n"; my $response = $ua->request($req); if ($response->is_error()) { printf " %s\n", $response->status_line; print "https request error!\n"; } else { my $content = $response->content(); #print "$content\n"; } print ""; if ( $response->is_success ) { print $response->as_string; }else { print $response->status_line; } }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum