|
|
|
|
|
|
| |
How to delete specific directory with all sub directories and files using FTP
| <?php
////////////////////////////////////////////////////////
// del directory with all sub folders and files
// By:
// Ahmed Samir
// asamir@asamir.net
// www.asamir.net
//
////////////////////////////////////////////////////////
function ftp_delAll($conn_id,$dst_dir){
$ar_files = ftp_nlist($conn_id, $dst_dir);
//var_dump($ar_files);
if (is_array($ar_files)){ // makes sure there are files
for ($i=0;$i<sizeof($ar_files);$i++){ // for each file
$st_file = basename($ar_files[$i]);
if($st_file == '.' || $st_file == '..') continue;
if (ftp_size($conn_id, $dst_dir.'/'.$st_file) == -1){ // check if it is a directory
ftp_delAll($conn_id, $dst_dir.'/'.$st_file); // if so, use recursion
} else {
ftp_delete($conn_id, $dst_dir.'/'.$st_file); // if not, delete the file
echo "delete <b><u>".$dst_dir."/".$st_file ." </u></b><br>";
}
}
sleep(1);
ob_flush() ;
}
$flag = ftp_rmdir($conn_id, $dst_dir); // delete empty directories
return $flag;
} // end of function ftp_delAll()
// connect to FTP server
$ftp_user_name = 'FTP_User_name';
$ftp_user_pass = 'FTP_Password';
$ftp_server = 'FTP_Server';
$dst_dir = 'directory_path'; // this is relative path of directory you want to delete
$conn_id = @ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// login into FTP server
if (@ftp_login($conn_id, $ftp_user_name, $ftp_user_pass)) {
echo "Connected as $ftp_user_name@$ftp_server\n";
// call function ftp_delAll()
if(@ftp_delAll($conn_id,$dst_dir)){
echo "<br><br><font size=3><b>delete ok </b></font> ";
}
}else{
echo "Couldn't connect as $ftp_user\n";
}
?> | | |
|
| Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML - Categories : PHP, Directories, FTP, Filesystem, HTML and PHP | | | Display list of files within current and subdirectories (recursively) showing
each file as an anchored link and each directory as a category header. Categories : Filesystem, Directories, Arrays, PHP | | | Extended Get File List Function Categories : PHP, Filesystem, Search, Directories | | | Moving folder hierarchy b/w server Categories : PHP, FTP, Filesystem | | | Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support Categories : PHP, FTP, Filesystem, PHP Classes, Compression | | | a file explorer for the web, filesystem php php3 files dirs directories pictures files windows linux system list ls scripts Categories : PHP, URLs, Directories, Filesystem | | | A function which places the path and name of all subdirectories into an array Categories : PHP, Filesystem, Arrays, Directories | | | Directory Viewer, Directory Content Viewer, Directory Structure to HTML.
This code will basically create a complete set of HTMLs to let a user
navigate through any directory you want. Excellent code for large file
sharing pages. Categories : Directories, Filesystem, PHP | | | PHP4 DirectoryIterator Class Categories : PHP, PHP Classes, Filesystem, Directories | | | List the content of the directory of your webserver where this small PHP Script resides. Categories : PHP, Filesystem, Directories, CSS | | | grab directory listings into an array the example prints out each
subdirectory in the main dir - further work is to be performed on this one Categories : Filesystem, PHP, Directories, Search, Utilities | | | A PHP Script that shows how to use FTP to run a shell script, read two local files and update data in a database. Categories : PHP, Filesystem, FTP, Date Time, Databases | | | Listing the 10 most recently updated files in a given dir by using last-
modified variable and printing to html with link to the file Categories : PHP, Directories, Filesystem | | | getDirArray(Path,Filter,Sorted): Returns an array of the files in a directory,
filtered by regular expression and either sorted or randomized. Good for
random pictures and graphics. Categories : PHP, Filesystem, Directories | | | Directory viewer, customize how you display the file structure, easy to
understand. Found out about PHP 3 days ago, and this is my first prog. Categories : HTML and PHP, Complete Programs, Directories, Filesystem, PHP | |
|
|
|