?
Solved

Unable to connect to FTP Server ftp_connect fails.

Posted on 2004-09-10
6
Medium Priority
?
484 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

771 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