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 回答