raimis100 Posted April 5, 2008 Share Posted April 5, 2008 Is ftp upload from server to server is possible ? Link to comment https://forums.phpfreaks.com/topic/99667-ftp-upload-from-server-to-server/ Share on other sites More sharing options...
raimis100 Posted April 5, 2008 Author Share Posted April 5, 2008 I need to help to fill variables in this script I want to copy files from http://wordpress6.890m.com/wp-includes/images/smilies to /www/4cats4.freehostia.com/ ?php $RemoteHost = "ftp.wordpress6.890m.com"; $RemotePort = 21; $RemoteUser = "a3322740"; $RemotePass = "xxx"; // this is the root path for the remote server $rootpath = "/public_html"; // Is this correct? // this is the physical path of the source directory. actually u can also use the relative path. $sourcepath = realpath("/wp-includes/images/smilies/")."/newsite"; // corrent ? // this directory name will only change the top most directory and not the inner one $destination_dir_name = "upload/"; // correct ? // make a FTP connection $con = ftp_connect($RemoteHost,$RemotePort); $login_result = ftp_login($con,$RemoteUser,$RemotePass); rec_copy ($sourcepath, $destination_dir_name, $con); if (function_exists("ftp_close")) { ftp_close($con); } 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); } } ?> Link to comment https://forums.phpfreaks.com/topic/99667-ftp-upload-from-server-to-server/#findComment-509870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.