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 : Moving folder hierarchy b/w server
Categories : PHP, FTP, Filesystem Click here to Update Your Picture
leaping langoor
Date : May 22nd 2005
Grade : 3 of 5 (graded 6 times)
Viewed : 9208
File : No file for this code example.
Images : No Images for this code example.
Search : More code by leaping langoor
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Had problems replicating your folder hierarchy on another server, Well, here's your solution :

ftp_transfer.php
<?
/**********************************************************
** FTP folder replica
**
** Author : leapinglangoor [ leapinglangoor@yahoo.co.in ]
** Date...: 12th Apr 2005
** Ver....: v1.00
**
**********************************************************/

function rec_copy ( $source_path, $destination_path, $con )
{
   
ftp_mkdir( $con, $destination_path );
   
ftp_site( $con, 'CHMOD 0777 '.$destination_path );
   
ftp_chdir( $con,$destination_path );
    if (
is_dir( $source_path ) )
    {
       
chdir( $source_path );
       
$handle=opendir( '.' );
        while ( (
$file = readdir( $handle ) )!==false )
        {
            if ( (
$file != "." ) && ( $file != ".." ) )
            {
                if (
is_dir( $file ) )
                {
                   
// here i am restricting the folder name 'propertyimages' from being copied to remote server.
                   
if( $file != "propertyimages" )
                    {
                       
rec_copy ( $source_path."/".$file, $file, $con );
                       
chdir( $source_path );
                       
ftp_cdup( $con );
                    }
                }
                if (
is_file( $file ) )
                {
                   
$fp = fopen( $file,"r" );
                   
// this will convert spaces to '_' so that it will not throw error.
                   
ftp_fput ( $con, str_replace( " ", "_", $file ), $fp,FTP_BINARY );
                   
ftp_site( $con, 'CHMOD 0755 '.str_replace( " ", "_", $file ) );
                }
            }
        }
       
closedir( $handle );
    }
}
?>



Example.php:
<?php

// make a FTP connection
$con = ftp_connect( "69.18.213.131",21 );
$login_result = ftp_login( $con,"username","password" );
// this is the root path for the remote server
$rootpath = "mainwebsite_html";
// this is the physical path of the source directory. actually u can also use the relative path.
$sourcepath = realpath( "../" )."/resdesk";
// this directory name will only change the top most directory and not the inner one
$destination_dir_name = "resdesk_".$account_id."/";
rec_copy ( $sourcepath, $destination_dir_name, $con );
if (
function_exists( "ftp_close" ) )
{
   
ftp_close( $con );
}
?>



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
List directory content - ftp explorer using a simple php code
Categories : PHP, FTP, Filesystem
Fetching product details from the commission junction website using php
Categories : PHP, FTP, Filesystem, Compression
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
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
include php3 files
Categories : Filesystem, PHP, Apache, Web Servers
Creating a Language File
Categories : PHP, Beginner Guides, Filesystem
Grab images from one or more URLs and save them to a specified local directory.
Categories : PHP, Filesystem, Strings, Arrays
Bs_IniHandler is a class that can read and write ini-style files (and strings)
Categories : PHP, Filesystem, PHP Classes
The toll booth
Categories : PHP, Java Script, Filesystem
Extended Get File List Function
Categories : PHP, Filesystem, Search, Directories
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