Solution to Transfer files by php ftp_put() : warning: ftp_put() [function.ftp-put]: Opening data connection
The whole thing did not work without this line.
ftp_pasv($conn_id, true);
Apparently with some ftp accounts you need to transfer in passive mode. As usual not documented by the client.
The full excerpt:
<?php function exporter_vdab_ftp($file_path,$file_name) { // set up basic connection $file = $file_path . '/'.$file_name; $ftp_server = VDAB_FTP_SERVER; $conn_id = ftp_connect($ftp_server);
// login with username and password $ftp_user_name = VDAB_FTP_USER; $ftp_user_pass = VDAB_FTP_PASS; $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection if ((!$conn_id) || (!$login_result)) { print "FTP connection has failed!"; print "Attempted to connect to $ftp_server for user $ftp_user_name"; return false; } else { print "Connected to $ftp_server, for user $ftp_user_name"; }
The blog contains tips for using the Drupal content management system/framework.
Dominique De Cooman is a drupal developer consultant working in Antwerp and Living in Gent. Feel free to contact me to hire me for your projects