1

我正在尝试将单个文件复制到 FTP 服务器。我在网上找到了这段代码,但无法让它工作。我收到以下错误消息:

Exception calling "UploadFile" with "2" argument(s): "The remote server returned an error: (550) File unavailable (e.g., file
no access)."
At C:\bin\Put-FTP.ps1:22 char:1
+ $webclient.UploadFile($uri, $File)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException

知道为什么会发生这种情况吗?我检查了目标 FTP 服务器,该用户具有写入、读取、删除和列出内容的完全访问权限。

谢谢!

$File = "C:\bin\emp1.xlsx"
$ftp = "ftp://user:password@ftp.server.com/User/emp1.xlsx"
"ftp url: $ftp"

$webclient = New-Object System.Net.WebClient
$uri = New-Object System.Uri($ftp)

"Uploading $File..."

$webclient.UploadFile($uri, $File)
4

0 回答 0