我需要在R中使用FTP上传文件,但该目录是从我服务器上的主目录中获取的。当我使用RCurl运行以下代码时,出现此错误:550 var: No such file or directory
:
ftpUpload(what = "./plots/daily/LastTwentyFour.png",
to = "ftp://spider/../../var/www/dashboard/img/LastTwentyFour.png",
verbose = TRUE,
userpwd = "REDACTED:REDACTED")
更具体地说,我得到了这个输出:
> PWD
< 257 "/home/dhadley" is the current directory
* Entry path is '/home/dhadley'
> CWD var
* ftp_perform ends with SECONDARY: 0
< 550 var: No such file or directory
* Server denied you to change to the given directory
* Connection #0 to host spider left intact
Error in function (type, msg, asError = TRUE) :
Server denied you to change to the given directory
当我尝试上传到我的主目录时,它会起作用:
ftpUpload(what = "./plots/daily/LastTwentyFour.png",
to = "ftp://spider/LastTwentyFour.png",
verbose = TRUE,
userpwd = "REDACTED:REDACTED")
我想问题是,如何在ftpUpload函数中的目录之间导航?或者,如果有另一种方法将文件从Windows上传到R中的Linux服务器,我也对此持开放态度。提前谢谢!
编辑:我有权访问相关目录,并能够在FileZilla中上传文件。不幸的是,我无法在服务器上更改我的主目录。
答案 0 :(得分:1)
我没有FTP服务器来测试它,但是
ftpUpload(what = "./plots/daily/LastTwentyFour.png",
to = "ftp://spider/var/www/dashboard/img/LastTwentyFour.png",
verbose = TRUE,
userpwd = "REDACTED:REDACTED", prequote="CWD /var/www/dashboard/img/")
prequote参数应该在尝试与给定路径交互之前将命令CWD
(更改工作目录)传递给服务器。 filezilla工作的原因是因为当您双击&#39; ..&#39;在gui中,它正在向FTP服务器发送CWD命令。