簡體   English   中英

PHP 中的 FTP_PUT 和遠程文件系統

[英]FTP_PUT in PHP and the remote File System

ftp_stream
The link identifier of the FTP connection.

remote_file
The remote file path.

local_file
The local file path.

mode
The transfer mode. Must be either FTP_ASCII or FTP_BINARY.

startpos
The position in the remote file to start uploading to.

https://www.php.net/manual/en/function.ftp-put.php

我仍然難以理解該鏈接中的許多內容。

題:

$upload = ftp_put($newconn->conn,$destination,$source, FTP_BINARY);

實際上目標和來源是什么?

$destination是遠程文件而$source只是文件?

如果我們想把上傳的內容放到各自的文件夾中。 我們是否必須將 startpos 位置作為該文件夾位置?

更新:

我正在使用這個:

$filename = "message.txt";
$source = getcwd()."/".$filename;
echo "The source file path is: ". $source;
echo "<br />";
$destination=getcwd()."/"."ftpsend/";
echo "The destination file path is: ". $destination;
echo "<br />";
$upload = ftp_put($newconn->conn,$destination,$source, FTP_BINARY);

我收到此錯誤:

錯誤

在 Filezilla 中,它顯示了這個路徑 → 在此處輸入圖片說明

根據文檔中的此評論

您不能放置目標文件的路徑

所以你必須使用ftp_chdir()來指定目標目錄。

您不應將目標目錄連接到getcwd() ,因為這是本地計算機上的路徑名,而不是遠程服務器上的路徑名。

$filename = "message.txt";
$source = getcwd()."/".$filename;
echo "The source file path is: ". $source;
echo "<br />";
$destination="/app.trafficopedia.com/ftp";
echo "The destination file path is: ". $destination;
echo "<br />";
ftp_chdir($newconn->conn,$destination);
$upload = ftp_put($newconn->conn,$filename,$source, FTP_BINARY);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM