Solved

Unable to connect to FTP Server ftp_connect fails.

Posted on 2004-09-10
6
403 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

19 Experts available now in Live!

Get 1:1 Help Now