WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Copy directory to directory with all sub-directory and files using FTP
Categories : PHP, FTP, Filesystem Click here to Update Your Picture
Ahmed Samir
Date : May 22nd 2008
Grade : 5 of 5 (graded 1 times)
Viewed : 11461
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ahmed Samir
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Copy directory to directory with all sub-directory and files using FTP


               <?php
       
////////////////////////////////////////////////////////
        // Copy directory to directory with all sub-directory and files using FTP
        // By:
        // Ahmed Samir
        // asamir@asamir.net
        // www.asamir.net
        //
        ////////////////////////////////////////////////////////

   
   
   
function ftp_copyAll($conn_id, $src_dir, $dst_dir) {
    if(
is_dir($dst_dir)){
    return
"<br> Dir <b> $dst_dir </b> Already exists  <br> ";
    }else{
     
$d = dir($src_dir);
     
ftp_mkdir($conn_id, $dst_dir);   echo "creat dir <b><u> $dst_dir </u></b><br>";
       while(
$file = $d->read()) { // do this for each file in the directory
         
if ($file != "." && $file != "..") { // to prevent an infinite loop
             
if (is_dir($src_dir."/".$file)) { // do the following if it is a directory
                 
ftp_copyAll($conn_id, $src_dir."/".$file, $dst_dir."/".$file); // recursive part
             
} else {
               
$upload = ftp_put($conn_id, $dst_dir."/".$file, $src_dir."/".$file, FTP_BINARY); // put the files
               
echo "creat files::: <b><u>".$dst_dir."/".$file ." </u></b><br>";
              }
          }
       
ob_flush() ;
       
sleep(1); 
      }
     
$d->close();
    }
    return
"<br><br><font size=3><b>All Copied  ok </b></font>";
    }
// end fn function ftp_copyAll
   
   
   
    //$ftp_user_name = 'asamirftp@phpeg.net';
    //$ftp_user_pass = 'asamirftp123';
    //$ftp_server = 'phpeg.net';
   
    // connect to FTP server
   
$ftp_user_name = 'FTP_User_name';
   
$ftp_user_pass = 'FTP_Password';
   
$ftp_server = 'FTP_Server';
       
   
   
$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";
       
ftp_set_option($conn_id, FTP_TIMEOUT_SEC, 1000);  // Set the network timeout to 10 seconds
   
   
$copy_result = ftp_copyAll($conn_id, 'Folder', 'FolderCopy');

    echo
$copy_result;

    }else{
    echo
"Couldn't connect as $ftp_user\n";
    }
   
    @
ftp_close($conn_id);    // colse of ftp_connect
    // @ftp_quit($conn_id);
   
   
?>




Using PHP to Delete a directory with all sub directories and files using FTP
Categories : PHP, FTP, Directories, Filesystem
Upload function using PHP's FTP abilities.
Categories : PHP, Filesystem, FTP
Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML -
Categories : PHP, Directories, FTP, Filesystem, HTML and PHP
Moving folder hierarchy b/w server
Categories : PHP, FTP, Filesystem
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
Fetching product details from the commission junction website using php
Categories : PHP, FTP, Filesystem, Compression
Finds files on your site, uses UNIX find command.
Categories : Complete Programs, Filesystem, PHP
This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given.
Categories : PHP, Arrays, Graphics, Filesystem
Working with files - putting file contents to a string / var
Categories : PHP, Filesystem, Variables, Strings
How to overide the Max_file_size barier
Categories : PHP, PHP Configuration, Filesystem
Keep() - maintenance function for backup folders
Categories : PHP, Filesystem, Maintenance
Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
How to create an empty file? (touch)
Categories : Filesystem, PHP