[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unable to connect to FTP Server ftp_connect fails.

Posted on 2004-09-10
6
Medium Priority
?
549 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
5 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …
Suggested Courses
Course of the Month18 days, 18 hours left to enroll

834 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