Home >Backend Development >PHP Problem >How to delete server files in php

How to delete server files in php

藏色散人
藏色散人Original
2020-08-21 10:47:373401browse

You can use the "ftp_delete" function to delete server files in PHP. The syntax is "ftp_delete(ftp_connection,file)". The parameter "ftp_connection" indicates the FTP connection to be used, and the parameter "file" indicates the file to be deleted. The path to the file.

How to delete server files in php

Recommended: "PHP Video Tutorial"

PHP ftp_delete() function

Definition and usage

ftp_delete() function deletes a file on the FTP server.

If successful, this function returns TRUE. On failure, returns FALSE and a warning.

Syntax

ftp_delete(ftp_connection,file)

Parameters

ftp_connection Required. Specifies the FTP connection to use.

file Required. Specifies the path of the file to be deleted.

Example

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
echo ftp_delete($conn,"test.txt");
ftp_close($conn);
?>

The above code will output:

1

The above is the detailed content of How to delete server files in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn