Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP not working

Status
Not open for further replies.

Trusts

Programmer
Feb 23, 2005
268
US
Hi,
The following routine will work on some servers, not on others. When it does not work, it gets as far as where it tried to connect, and then nothing happens. The echo numbers are for seeing how far the programming goes. When it does not work, it echoes "2" and then just keeps spinning its wheels. It does not report that the connection failed - just that nothing happens.

I assume it has something to do with the FTP Server-path? I tested this from server1 to server2 - that worked. But from server2 to server1 it does not work. Both have FTP turned on.

Both can connect to with the FTP credentials with a regular FTP program.

One of the connections though, is where it connects just with the FTP address. Then you login after that, perhaps that has something to do with it?

Thanks,
Trusts

..... the code....:

<?php
$ftp_server="xxxxxx";
$ftp_user_name="xxxxxx";
$ftp_user_pass="xxxxx";
echo '1<br />';
$file = 'myfile.csv';
$remote_file = 'myfile.csv';
echo '2<br />';
// login with username and password
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
echo '3<br />';
// turn passive mode on
ftp_pasv($conn_id, true);
echo '4<br />';
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
echo '5<br />';
// upload a file
if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) {
echo "3 successfully uploaded $file\n";
} else {
echo "There was a problem while uploading $file\n";
}
// close the connection
ftp_close($conn_id);
echo 'done';
?>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top