简体   繁体   English

如何使用RCurl中的FTP将文件上传到主目录所在的目录中?

[英]How to upload file to directory that is up from home directory using FTP in RCurl?

I need to upload a file using FTP in R, but the directory is up from my home directory on the server. 我需要在R中使用FTP上传文件,但是该目录位于服务器上的主目录上。 When I run the following code using RCurl, I get this error: 550 var: No such file or directory : 当我使用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")

More specifically, I get this output: 更具体地说,我得到以下输出:

> 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

It works when I try to upload to my home directory: 当我尝试上传到主目录时,它可以工作:

ftpUpload(what = "./plots/daily/LastTwentyFour.png",
      to = "ftp://spider/LastTwentyFour.png",
      verbose = TRUE,
      userpwd = "REDACTED:REDACTED")

I guess the question is, how do I navigate between directories within the ftpUpload function? 我想问题是,如何在ftpUpload函数中的目录之间导航? Or, if there is another way to upload a file from Windows to a Linux server in R, I am open to that too. 或者,如果有另一种方法可以将Windows中的文件上传到R中的Linux服务器,我也可以接受。 Thanks in advance! 提前致谢!

EDIT: I have write access to the directory in question, and am able to upload files in FileZilla. 编辑:我对有问题的目录具有写访问权,并且能够在FileZilla中上传文件。 I cannot change my home directory on the server, unfortunately. 不幸的是,我无法在服务器上更改主目录。

I don't have a FTP server to test this on but something like 我没有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/")

The prequote argument should pass the command CWD (change working directory) to the server before it tries to interact with the given path. prequote参数应在尝试与给定路径进行交互之前将命令CWD (更改工作目录)传递给服务器。 The reason filezilla works is because when you double click the '..' in the gui, it is sending the FTP server a CWD command. filezilla起作用的原因是,当您双击gui中的“ ..”时,它将向FTP服务器发送CWD命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM