|
|
|
|
|
|
| |
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 );
}
?> | | |
|
| List directory content - ftp explorer using a simple php code Categories : PHP, FTP, Filesystem | | | Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support Categories : PHP, FTP, Filesystem, PHP Classes, 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 | | | Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML - Categories : PHP, Directories, FTP, Filesystem, HTML and PHP | | | file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | php jump urls...the best way Categories : PHP, URLs, Filesystem | | | Simple way to replace a variable value in a .conf (.ini) file using a
webbrowser - the first stage of a complete universal configuration editor Categories : PHP, Regexps, Code Editors, Filesystem | | | 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 | | | File Explorer, browse, upload, download and edit your web site files with only a browser and a HTTP connection. Categories : Complete Programs, Content Management, Filesystem, PHP | | | Get the correct extension and MIME types of an image, even when the filename is incorrect. Categories : PHP, Filesystem, General SQL | | | very simple ftp class Categories : PHP, PHP Classes, FTP | | | Check for functional file links (broken Files)
Categories : PHP, Data Validation, FTP, Regexps, Arrays | | | Simple pipe delimited file export program that downloads to a local machine Categories : PHP, Filesystem, Databases, MySQL, HTTP | | | PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP, Email, Beginner Guides, Filesystem | |
|
|
|