Solved

Unable to connect to FTP Server ftp_connect fails.

Posted on 2004-09-10
6
414 Views
Last Modified: 2007-12-19
Greets all, I am trying to establish an FTP connection to a server which is through our VPN.  I am able to ping the server and I can access it from the computer I'm running this from but from the below code all I get is :

ERROR! Unable to connect to xx.xx.xx.xxx.  I've checked the IP , username and password and all are OK.  Is there maybe something IM missing? is there a port I will need to open up on my end or theirs that's currently being blocked when using ftp_connect ??

Thank you for your help in advance... The following is the complete code :

if( file_exists( $current_dir."/".$filename.".mirror") )            //Download from Mirror location in file
{
list( $ftp_server_address, $ftp_user_name, $ftp_user_pass) = get_ftp_information( $user_branch );
                  
if(!($ftp = ftp_connect( $ftp_server_address ) ) )
{
     place_header( "ERROR! Unable to connect to $ftp_server_address" );
     die;
}
else
     echo "Connected to $ftp_server_address";
                  
if(!($login_result = ftp_login($ftp, "$ftp_user_name", "$ftp_user_pass") ))
{
     place_header("Unable to login!");
     die;
}
else
     echo "Login successful";
                  
if( (!$ftp) || (!$login_result) )
{
     place_header( "FTP connection has failed!  Attempted to connect to $ftp_server for user $user" );
     die;
}
else
     echo "Connected to $ftp_server, for user $user";

$download = ftp_get($ftp, "$current_dir/$filename", "$current_dir/$filename", FTP_BINARY);
                  
if( !$download )
     echo "Ftp download has failed!";
else
     echo "Downloaded $filename to local as $local_file_name";
                  
ftp_quit( $ftp );
}
0
Comment
Question by:darksinclair
  • 2
  • 2
6 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 12031445
Maybe there are spaces in the $ftp_server_address

try if(!($ftp = ftp_connect( trim($ftp_server_address) ) ) )
0
 
LVL 5

Author Comment

by:darksinclair
ID: 12031588
--> Sorry hernst42, I checked that stuff, I think this question is in the wrong spot and it's a problem with the VPN actually.

Thanks for the help,

Cheers,
0
 
LVL 48

Expert Comment

by:hernst42
ID: 12031629
You said that you can connect to that server
> I can access it from the computer I'm running this from but from the below code all I get is...
So can you access the ftp-server from the shell of the computer you tried it or not?

If a normal ftp-client can connect it should also work for PHP. If you can't connect from your machine to the ftp-server make sure port 21 and 20 are open and the ftp-server can connect from port 20 to any port on you machine. Are there any NAT-Gatewyas in that way ??
0
 
LVL 5

Author Comment

by:darksinclair
ID: 12031734
This was a stupid problem... I logged off the server that was running the PHP instead of disconnecting.. so the Contivity VPN client was being closed when i logged off.  :(

0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 12064292
Please read entire thread.  Asker solved or content important.
Closed, 250 points refunded.
ee_ai_construct (replacement part #xm34)
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now