Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict ; use warnings ; use CGI ; use Net::FTP; my $cgi = CGI->new(); my $file = $cgi->param( 'upload' ) || ''; do_ftp($file); sub do_ftp { my $filename = @_; return unless $filename ; $cgi->upload( 'upload' ); my $tmp = $cgi->tmpFileName( $filename ) ; rename( $tmp, $filename ) ; chmod 0664, $filename ; my $host = 'xxx'; my $user = 'user'; my $pass = 'pass'; my $ftpdir = '/'; my $ftp = Net::FTP->new($host, Debug => 0) or die "Could not connect to '$host': $@"; $ftp->login($user, $pass) or die sprintf "Could not login: %s", $ftp->message; $ftp->cwd($ftp_dir) or die sprintf "Could not login: %s", $ftp->message; # FTP file. $ftp->put($filename) or die "Cannot put file ", $ftp->message; $ftp->quit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error ftping file with Net::FTP
by thanos1983 (Parson) on Aug 16, 2017 at 14:55 UTC | |
by Anonymous Monk on Aug 16, 2017 at 15:06 UTC | |
by Anonymous Monk on Aug 16, 2017 at 15:54 UTC | |
by hippo (Archbishop) on Aug 16, 2017 at 16:08 UTC | |
by Anonymous Monk on Aug 16, 2017 at 17:25 UTC | |
|
Re: Error ftping file with Net::FTP
by dbander (Scribe) on Aug 16, 2017 at 15:00 UTC | |
by afoken (Chancellor) on Aug 16, 2017 at 15:49 UTC | |
by Anonymous Monk on Aug 16, 2017 at 22:06 UTC | |
by afoken (Chancellor) on Aug 17, 2017 at 10:17 UTC |