downloads | documentation | faq | getting help | mailing lists | reporting bugs | sites | links | my 
search for in the  
view the version of this page
Last updated: Thu, 21 Aug 2003


(PHP 3>= 3.0.13, PHP 4 )

ftp_delete -- Deletes a file on the FTP server


bool ftp_delete ( resource ftp_stream, string path)

ftp_delete() deletes the file specified by path from the FTP server.

Returns TRUE on success or FALSE on failure.

add a note add a note User Contributed Notes
lucas at rufy dot com
04-Aug-2003 03:48
The following function will recursively delete any files in a destination directory through FTP. See for more information.

NOTE: use full path name for the destination directory

function ftp_rmAll($conn_id,$dst_dir){
    $ar_files = ftp_nlist($conn_id, $dst_dir);
    if (is_array($ar_files)){ // makes sure there are files
        for ($i=0;$i<sizeof($ar_files);$i++){ // for each file
            $st_file = $ar_files[$i];
            if (ftp_size($conn_id, $st_file) == -1){ // check if it is a directory
                ftp_rmAll($conn_id, $st_file); // if so, use recursion
            } else {
                ftp_delete($conn_id, $st_file); // if not, delete the file
    ftp_rmdir($conn_id, $dst_dir); // delete empty directories

 Last updated: Thu, 21 Aug 2003
show source | credits | sitemap | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by:
Last updated: Sat 01 Nov 2003 04:13:36 EST EST