Home > Archive > PERL Programming > September 2005 > CGI perlscript that downloads a URL file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
CGI perlscript that downloads a URL file
|
|
|
| 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
| |
| Paul Lalli 2005-08-31, 7:55 am |
| 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...b/LWP/Simple.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
| |
|
| Thank you very much, Paul!
I worked very well!
Best Regards
Bluey
|
|
|
|
|