CGI perlscript that downloads a URL file
am 31.08.2005 12:53:57 von Bluey
Hello!
I have a question about a CGI perl script.
I have a form that i fill a http file reference into.
Then I want the perl CGI program to pick up the URL and download the
file into a local path thats on the server.
I got everything right except for the part that downloads the URL file
to the local server path.
Can anyone please help me?
Best regards
Bluey
Re: CGI perlscript that downloads a URL file
am 31.08.2005 14:38:30 von Paul Lalli
Bluey wrote:
> Hello!
>
> I have a question about a CGI perl script.
>
> I have a form that i fill a http file reference into.
>
> Then I want the perl CGI program to pick up the URL and download the
> file into a local path thats on the server.
>
> I got everything right except for the part that downloads the URL file
> to the local server path.
>
> Can anyone please help me?
Take a look at the LWP::Simple module, available on CPAN:
http://search.cpan.org/~gaas/libwww-perl-5.803/lib/LWP/Simpl e.pm
[untested]
#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;
my $url = 'http://www.google.com/';
my $filename = 'google.txt';
my $response = getstore($url, $filename);
if ($response != 200) {
print "Error downloading, error code: $response\n";
}
__END__
Paul Lalli