PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<ftp_closeftp_delete>
view the version of this page
Last updated: Thu, 21 Aug 2003

ftp_connect

(PHP 3>= 3.0.13, PHP 4 )

ftp_connect -- Opens an FTP connection

Description

resource ftp_connect ( string host [, int port [, int timeout]])

Returns a FTP stream on success or FALSE on error.

ftp_connect() opens an FTP connection to the specified host. host shouldn't have any trailing slashes and shouldn't be prefixed with ftp://. The port parameter specifies an alternate port to connect to. If it is omitted or set to zero, then the default FTP port, 21, will be used.

The timeout parameter specifies the timeout for all subsequent network operations. If omitted, the default value is 90 seconds. The timeout can be changed and queried at any time with ftp_set_option() and ftp_get_option().

Note: The timeout parameter became available in PHP 4.2.0.

Example 1. ftp_connect() example

<?php

$ftp_server = "ftp.example.com";

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); 

?>

See also ftp_close(), and ftp_ssl_connect().



add a note add a note User Contributed Notes
ftp_connect
thomas g.
04-Mar-2003 07:35
always keep an eye on the ftp_pasv function, if you are behind a firewall or nat'ed and your scripts won't do a listing or put files to the ftp
04-Jan-2003 05:03
As mentiond before ftp_connect($hostip, 2160, 4) needs a hostname to resolve. I found out that trying to resolve private FTPs of users visiting your homepage usally fails, so don't wonder.

I'd be interested in knowing how to get stats about FTP Servers among your visitors. fsockopen() wasn't satisfying either.
kent at digitalinkpen dot com
16-Mar-2001 07:43
We recompiled two versions, PHP 4.0.1 and 4.0RC1 to add FTP capability.  4.0.1 requires "--enable-ftp" but 4.0RC1 needs to be configured with the "--with-ftp" option.  Not sure at what point this change was made, so be aware.
ro_1010 at yahoo dot com
21-Sep-2000 06:07
Hi everyone,
            To use this function with PHP4, Apache web server under Windows 98 u need to
1. Add extension=php_ftp.dll under the windows extension of php.ini file.
2. to check u may run phpinfo(). u should see ftp under the Additional Modules heading.
3. note that u may specify the IP address instead of ftp.domain.com for the host name.
 
ro
pdazero at yahoo dot com
16-Aug-2000 07:27
People, for ftp to work you must do ./configure --enable-ftp in php4.

Do ./configure --help for further info

.Pda0

<ftp_closeftp_delete>
 Last updated: Thu, 21 Aug 2003
show source | credits | sitemap | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: http://php.mirrors.ilisys.com.au/
Last updated: Sat 01 Nov 2003 04:13:36 EST EST