Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> PHP

Hàm ftp_delete() trong PHP


Hàm ftp_delete() xóa một tập tin trên máy chủ FTP.

Cú pháp

ftp_delete($conn, $myfile)

Tham số

  • conn – Kết nối FTP.

  • myfile – Tập tin cần xóa.

Giá trị trả về

Hàm trả về TRUE nếu thành công, FALSE nếu thất bại.

Ví dụ

<?php
$ftp_server = "192.168.0.4";
$ftp_user = "amit";
$ftp_pass = "tywg61gh";
$con = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$myfile = "E:/new/demo.txt";
if (ftp_delete($con, $myfile)) {
    echo "The file deleted!";
} else {
    echo "The file cannot be deleted!";
}
ftp_close($con);
?>