2

ファイルを元の場所に復元しようとしています。FTP サーバーにログインした後、特定のディレクトリに配置するにはどうすればよいですか。今のところ、ルートディレクトリに移動します...

    $f = Net::FTP->new($server, Debug => 0);
    $f->login($username, $passwd) or &fail;
    $msg = "".$f->message."";
    $f->binary();
    $f->put($newfile) or &fail;
    &pass;
4

1 に答える 1

3

最初にディレクトリを変更してみてください:

$f->cwd('/somedirectory') 
    or die "Cannot change working directory ", $ftp->message;

ドキュメントから:

cwd ( [ DIR ] )

Attempt to change directory to the directory given in $dir.  If
$dir is "..", the FTP "CDUP" command is used to attempt to move up
one directory. If no directory is given then an attempt is made to
change the directory to the root directory.
于 2012-07-03T12:44:46.507 に答える