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
Bluey [ Mi, 31 August 2005 12:53 ] [ ID #947403 ]

Re: CGI perlscript that downloads a URL file

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
Paul Lalli [ Mi, 31 August 2005 14:38 ] [ ID #947404 ]

Re: CGI perlscript that downloads a URL file

Thank you very much, Paul!

I worked very well!

Best Regards

Bluey
Bluey [ Do, 01 September 2005 11:16 ] [ ID #949063 ]
Perl » alt.perl » CGI perlscript that downloads a URL file

Vorheriges Thema: Perl memory policy
Nächstes Thema: INTERNAL SERVER ERROR