Hướng dẫn php ftp delete file - php ftp xóa tập tin

(Php 4, Php 5, Php 7, Php 8)

ftp_delete - xóa một tệp trên máy chủ FTPDeletes a file on the FTP server

Sự mô tả

Thông số

ftp

Một thể hiện kết nối ftp \.FTP\Connection instance.

filename

Các tập tin để xóa.

Trả về giá trị

Trả về true khi thành công hoặc false về thất bại.true on success or false on failure.

Thay đổi

Phiên bảnSự mô tả
8.1.0 Thông sốFTP\Connection instance now; previously, a resource was expected.

ftp

Một thể hiện kết nối ftp \.ftp_delete() example

$file 'public_html/old.txt';// set up basic connection
$ftp ftp_connect($ftp_server);// login with username and password
$login_result ftp_login($ftp$ftp_user_name$ftp_user_pass);// try to delete $file
if (ftp_delete($ftp$file)) {
 echo 
"$file deleted successful\n";
} else {
 echo 
"could not delete $file\n";
}
// close the connection
ftp_close($ftp);
?>

filename

Các tập tin để xóa.

You can make a script delete itself with ftp_delete!

It's pretty useful when creating an install script which you want to destroy at the end of the installation to prevent it from being run later.

On Linux machines, very often the user uploads third party scripts, and gets asked to CHMOD this and delete that manually because the webserver user is different from the FTP user ; make them enter their FTP info and get rid of the tedious file manipulation step!

Be careful, though. You will need to flush the output buffer and call ftp_delete at the end of the script, or else the script will die before it fully executes. Look up ob_end_flush for more info.

filename0

Trả về giá trị

Trả về true khi thành công hoặc false về thất bại.

filename1

filename2

filename0

Thay đổi

Trả về true khi thành công hoặc false về thất bại.

filename4

filename5

filename0

Thay đổi

Phiên bản

filename7