[英]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);
我收到此錯誤:
根據文檔中的此評論
您不能放置目標文件的路徑
所以你必須使用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.