Reply to comment

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";
  }
  
  
//turn passive mode on
  
ftp_pasv($conn_idtrue);

  
// upload the file
  
$upload ftp_put($conn_idVDAB_REMOTE_PATH '/' $file_name$fileFTP_BINARY);

  
// close the FTP stream
  
ftp_close($conn_id);
}
?>

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><img><p><b><i><table><th><tr><td><blockquote><br /><img /><tbody><span><strike>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <codes>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.