sean04 Posted October 26, 2010 Share Posted October 26, 2010 What I'm trying to do is copy all files from one server to another folder on another server. Here is what I have have so far.. <?PHP //connection settings $ftp_server = "server"; $ftp_user_name = "user"; $ftp_user_pass = "pass"; $dir = "/var/test/"; $destination_file = "/test/"; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; } if (ftp_chdir($conn_id, $dir)) { echo " <br/>Current directory is now: " . ftp_pwd($conn_id) . "\n<p/>"; } else { echo "Couldn't change directory\n<p/>"; } $buff = ftp_rawlist($conn_id, $dir); foreach($buff as $files) { echo $files. "<br/>"; if (ftp_get($conn_id, $destination_file."test.file", $dir."test.txt", FTP_BINARY)) { echo "<br/>Successfully written to $destination_file\n"; } else { echo "There was a problem\n"; } ?> That doesn't work. Any ideas? Thanks, Sean Quote Link to comment https://forums.phpfreaks.com/topic/216914-php-ftp-copying-files-from-server-to-server/ Share on other sites More sharing options...
BlueSkyIS Posted October 26, 2010 Share Posted October 26, 2010 what doesn't work? Quote Link to comment https://forums.phpfreaks.com/topic/216914-php-ftp-copying-files-from-server-to-server/#findComment-1126824 Share on other sites More sharing options...
sean04 Posted October 26, 2010 Author Share Posted October 26, 2010 Copying files Quote Link to comment https://forums.phpfreaks.com/topic/216914-php-ftp-copying-files-from-server-to-server/#findComment-1126834 Share on other sites More sharing options...
BlueSkyIS Posted October 26, 2010 Share Posted October 26, 2010 so you are sure that the connection is working and the chdir works fine, but when you try to put the file on the other server, you get some kind of error? sounds like a permissions issue on the target server. Quote Link to comment https://forums.phpfreaks.com/topic/216914-php-ftp-copying-files-from-server-to-server/#findComment-1126839 Share on other sites More sharing options...
sean04 Posted October 26, 2010 Author Share Posted October 26, 2010 Yes the connection works and the chdir. I do get a permissions error sometimes but I have full permissions. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/216914-php-ftp-copying-files-from-server-to-server/#findComment-1126842 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.