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

ftp_delete

(PHP 3>= 3.0.13, PHP 4 )

ftp_delete -- Deletes a file on the FTP server

Description

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
ftp_delete
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 http://rufy.com/tech/archives/000026.html 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
}

<ftp_connectftp_exec>
 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: http://php.mirrors.ilisys.com.au/
Last updated: Sat 01 Nov 2003 04:13:36 EST EST