Jump to content

PHP FTP functionality not working on just one server.


scott.stephan

Recommended Posts

Here's the rub: On one of our hosted sites, anything FTP'ed via PHP FTP functions will not work. I wrote a small program to test this:

 

<?php
// set up basic connection
$ftp_server="ftp.ftp.ftp";
$conn_id = ftp_connect($ftp_server); 
$ftp_user_name="ftp";
$ftp_user_pass="ftp";
$destination_file="/ftp/web/content/ftptest/testfromftpserver.txt";
$source_file="test.txt";
// 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";
    }

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 

// check upload status
if (!$upload) { 
        echo "FTP upload has failed!";
    } else {
        echo "Uploaded $source_file to $ftp_server as $destination_file";
    }

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

 

Names changed to protect the innocent :).

 

Anyhow, I had 3 servers I was testing with. We'll call them A, B and Problem.

 

A->B is fine. B->A is fine.

 

Problem->A or Problem->B, I get "Connected to ftp.ftp.ftp, for user ftp FTP upload has failed!". It also takes about 45 seconds to return the error, whereas in A->B or vice versa it takes about 5 seconds to get a success result.

 

I'm guessing this could be a server configuration error, or a php.ini thing, but I'm stumped. Thoughts?

It has been quite awhile since I was around SSH. Anyway, I managed to open a session, pop into TelNet and it seemed like any attempt to OPEN or PING another server ended either with an outright refusal (Unable, Connection refused) or dead air.

 

Thoughts?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.