ftp_delete
(PHP 4, PHP 5, PHP 7, PHP 8)
ftp_delete — 刪除 FTP 伺服器上的一個檔案
說明
ftp_delete(resource
$ftp_stream
, string $path
): bool
ftp_delete() 函式用來刪除 FTP 伺服器上的一個由參數
path
指定的的檔案。
參數
-
ftp_stream
-
FTP 連線的鏈接識別符號。
-
path
-
要刪除的檔案。
返回值
成功時返回 true
, 或者在失敗時返回 false
。
範例
示例 #1 ftp_delete() 例子
<?php
$file = 'public_html/old.txt';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// try to delete $file
if (ftp_delete($conn_id, $file)) {
echo "$file deleted successful\n";
} else {
echo "could not delete $file\n";
}
// close the connection
ftp_close($conn_id);
?>