in reply to Re: LWP Credentials Login Problem to Download Zip Files
in thread LWP Credentials Login Problem to Download Zip Files

This is what I added:
open(ZIP, ">$filename"); binmode ZIP; print ZIP $response->content; close(ZIP); print "Content-Disposition: attachment; filename=$filename\n"; print "Content-type: application/zip\n\n";
But for some reason the filename is just "download". Hmm! Close but no cigar. Need help!

Replies are listed 'Best First'.
Re^3: LWP Credentials Login Problem to Download Zip Files
by ikegami (Patriarch) on Aug 26, 2004 at 16:45 UTC
    Oh! this is being executed in a CGI script? I don't know the answer. Try doing a search of this site, or start a new thread about this new problem so people who might know the answer notice it.
Re^3: LWP Credentials Login Problem to Download Zip Files
by noniekimp (Sexton) on Sep 01, 2004 at 18:04 UTC
    I was running into problems trying to get the zip file to download. I was getting the prompt to download, but the file was coming up empty. The problem I was running into was that the connection to the browser is a stateless connection, and lost the credentials that was being used in getting the file in the first step. Had to save the file locally to a temp directory and create a direct link, (files are deleted after 24 hours) allowing people to download the file directly. This is what I ended up doing:
    $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>";
    Don't think there was a solution to downloading the file via the a prompt.