in reply to Re^2: LWP Credentials Login Problem to Download Zip Files
in thread LWP Credentials Login Problem to Download Zip Files
Don't think there was a solution to downloading the file via the a prompt.$filename = 'test.zip'; # get file from external ftp use LWP::UserAgent; use HTTP::Request::Common; my $url = "http://www.domain.com/$filename"; my $ua = LWP::UserAgent->new(keep_alive=>1); my $headers = HTTP::Headers->new(); $headers->authorization_basic('user', 'pass'); my $request = new HTTP::Request(GET => $url, $headers); my $response = $ua->request($request); print "response:" . $response->code . "<br>"; # save file locally $filepath = "e:/myfolder/Data/$filename"; open(ZIP, ">$filepath"); binmode ZIP; print ZIP $response->content; close(ZIP); # provide link to download file print "Download file <a href="http://www.localftp.com/Data/$filename"> +here</a>";
|
|---|