FTP 在 Perl 中上传目录和子目录
FTP upload directory and subdirectories in Perl
我正在尝试 FTP 一个目录,该目录包含使用 Perl 的文件和图像的子目录。
我尝试在 Net::FTP::Recursive
下使用 $ftp->rput()
。但这会上传本地当前工作目录下的所有文件。
有没有办法给出本地目录的路径,所有的文件夹和文件都上传了。请指导。
您需要临时更改自己的工作目录。
rput ( [FlattenTree => 1] [,RemoveLocalFiles => 1] )
The recursive put
method call. This will recursively send the local current working
directory and its contents to the ftp object's current working
directory.
Perl 的 builtin chdir
can be used to change the directory. Use the Cwd module 获取当前版本,如果您需要返回。
use strict;
use warnings;
use Cwd;
use Net::FTP::Recursive;
# ...
# get the current directory
my $old_current_dir = getcwd();
# change directory to the one you want to upload
chdir('path/to/updloaddir');
# upload
$ftp->rput();
# change back
chdir($old_current_dir);
我正在尝试 FTP 一个目录,该目录包含使用 Perl 的文件和图像的子目录。
我尝试在 Net::FTP::Recursive
下使用 $ftp->rput()
。但这会上传本地当前工作目录下的所有文件。
有没有办法给出本地目录的路径,所有的文件夹和文件都上传了。请指导。
您需要临时更改自己的工作目录。
rput ( [FlattenTree => 1] [,RemoveLocalFiles => 1] )
The recursive put method call. This will recursively send the local current working directory and its contents to the ftp object's current working directory.
Perl 的 builtin chdir
can be used to change the directory. Use the Cwd module 获取当前版本,如果您需要返回。
use strict;
use warnings;
use Cwd;
use Net::FTP::Recursive;
# ...
# get the current directory
my $old_current_dir = getcwd();
# change directory to the one you want to upload
chdir('path/to/updloaddir');
# upload
$ftp->rput();
# change back
chdir($old_current_dir);