<HTML ><HEAD ><TITLE >FTP functions</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Function Reference" HREF="funcref.html"><LINK REL="PREVIOUS" TITLE="fribidi_log2vis" HREF="function.fribidi-log2vis.html"><LINK REL="NEXT" TITLE="ftp_cdup" HREF="function.ftp-cdup.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="reference" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.fribidi-log2vis.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ftp-cdup.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="reference" ><A NAME="ref.ftp" ></A ><DIV CLASS="TITLEPAGE" ><H1 CLASS="title" >XXXIII. FTP functions</H1 ><DIV CLASS="PARTINTRO" ><A NAME="AEN28198" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.intro" ></A >Introduction</H1 ><P > The functions in this extension implement client access to file servers speaking the File Transfer Protocol (FTP) as defined in <A HREF="http://www.faqs.org/rfcs/rfc959.html" TARGET="_top" >http://www.faqs.org/rfcs/rfc959.html</A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.requirements" ></A >Requirements</H1 ><P >No external libraries are needed to build this extension.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.installation" ></A >Installation</H1 ><P > In order to use FTP functions with your PHP configuration, you should add the <TT CLASS="option" >--enable-ftp</TT > option when installing PHP 4 or <TT CLASS="option" >--with-ftp</TT > when using PHP 3. </P ><P > The windows version of <TT CLASS="literal" >PHP</TT > has built in support for this extension. You do not need to load any additional extension in order to use these functions.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.configuration" ></A >Runtime Configuration</H1 ><P >This extension has no configuration directives defined in <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.resources" ></A >Resource Types</H1 ><P > This extension uses one resource type, which is the link identifier of the FTP connection, returned by <A HREF="function.ftp-connect.html" ><B CLASS="function" >ftp_connect()</B ></A >. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.constants" ></A >Predefined Constants</H1 ><P > The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >FTP_ASCII</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_TEXT</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_BINARY</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_IMAGE</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_TIMEOUT_SEC</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > See <A HREF="function.ftp-set-option.html" ><B CLASS="function" >ftp_set_option()</B ></A > for information. </P ></DD ></DL ></DIV ><P > The following constants were introduced in PHP 4.3.0. </P ><P ></P ><DIV CLASS="variablelist" ><DL ><DT ><TT CLASS="constant" ><B >FTP_AUTOSEEK</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > See <A HREF="function.ftp-set-option.html" ><B CLASS="function" >ftp_set_option()</B ></A > for information. </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_AUTORESUME</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > Automatically determine resume position and start position for GET and PUT requests (only works if FTP_AUTOSEEK is enabled) </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_FAILED</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > Asynchronous transfer has failed </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_FINISHED</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > Asynchronous transfer has finished </P ></DD ><DT ><TT CLASS="constant" ><B >FTP_MOREDATA</B ></TT > (<A HREF="language.types.integer.html" >integer</A >)</DT ><DD ><P > Asynchronous transfer is still active </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.examples" ></A >Examples</H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN28292" ></A ><P ><B >Example 1. FTP example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; exit; } else { echo "Connected to $ftp_server, for user $ftp_user_name"; } // upload the file $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload status if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; } // close the FTP stream ftp_close($conn_id); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Table of Contents</B ></DT ><DT ><A HREF="function.ftp-cdup.html" >ftp_cdup</A > -- Changes to the parent directory</DT ><DT ><A HREF="function.ftp-chdir.html" >ftp_chdir</A > -- Changes directories on a FTP server</DT ><DT ><A HREF="function.ftp-close.html" >ftp_close</A > -- Closes an FTP connection</DT ><DT ><A HREF="function.ftp-connect.html" >ftp_connect</A > -- Opens an FTP connection</DT ><DT ><A HREF="function.ftp-delete.html" >ftp_delete</A > -- Deletes a file on the FTP server</DT ><DT ><A HREF="function.ftp-exec.html" >ftp_exec</A > -- Requests execution of a program on the FTP server</DT ><DT ><A HREF="function.ftp-fget.html" >ftp_fget</A > -- Downloads a file from the FTP server and saves to an open file</DT ><DT ><A HREF="function.ftp-fput.html" >ftp_fput</A > -- Uploads from an open file to the FTP server</DT ><DT ><A HREF="function.ftp-get-option.html" >ftp_get_option</A > -- Retrieves various runtime behaviours of the current FTP stream</DT ><DT ><A HREF="function.ftp-get.html" >ftp_get</A > -- Downloads a file from the FTP server</DT ><DT ><A HREF="function.ftp-login.html" >ftp_login</A > -- Logs in to an FTP connection</DT ><DT ><A HREF="function.ftp-mdtm.html" >ftp_mdtm</A > -- Returns the last modified time of the given file</DT ><DT ><A HREF="function.ftp-mkdir.html" >ftp_mkdir</A > -- Creates a directory</DT ><DT ><A HREF="function.ftp-nb-continue.html" >ftp_nb_continue</A > -- Continues retrieving/sending a file (non-blocking)</DT ><DT ><A HREF="function.ftp-nb-fget.html" >ftp_nb_fget</A > -- Retrieves a file from the FTP server and writes it to an open file (non-blocking)</DT ><DT ><A HREF="function.ftp-nb-fput.html" >ftp_nb_fput</A > -- Stores a file from an open file to the FTP server (non-blocking)</DT ><DT ><A HREF="function.ftp-nb-get.html" >ftp_nb_get</A > -- Retrieves a file from the FTP server and writes it to a local file (non-blocking)</DT ><DT ><A HREF="function.ftp-nb-put.html" >ftp_nb_put</A > -- Stores a file on the FTP server (non-blocking)</DT ><DT ><A HREF="function.ftp-nlist.html" >ftp_nlist</A > -- Returns a list of files in the given directory</DT ><DT ><A HREF="function.ftp-pasv.html" >ftp_pasv</A > -- Turns passive mode on or off</DT ><DT ><A HREF="function.ftp-put.html" >ftp_put</A > -- Uploads a file to the FTP server</DT ><DT ><A HREF="function.ftp-pwd.html" >ftp_pwd</A > -- Returns the current directory name</DT ><DT ><A HREF="function.ftp-quit.html" >ftp_quit</A > -- Closes an FTP connection</DT ><DT ><A HREF="function.ftp-rawlist.html" >ftp_rawlist</A > -- Returns a detailed list of files in the given directory</DT ><DT ><A HREF="function.ftp-rename.html" >ftp_rename</A > -- Renames a file on the FTP server</DT ><DT ><A HREF="function.ftp-rmdir.html" >ftp_rmdir</A > -- Removes a directory</DT ><DT ><A HREF="function.ftp-set-option.html" >ftp_set_option</A > -- Set miscellaneous runtime FTP options</DT ><DT ><A HREF="function.ftp-site.html" >ftp_site</A > -- Sends a SITE command to the server</DT ><DT ><A HREF="function.ftp-size.html" >ftp_size</A > -- Returns the size of the given file</DT ><DT ><A HREF="function.ftp-ssl-connect.html" >ftp_ssl_connect</A > -- Opens an Secure SSL-FTP connection</DT ><DT ><A HREF="function.ftp-systype.html" >ftp_systype</A > -- Returns the system type identifier of the remote FTP server</DT ></DL ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.fribidi-log2vis.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ftp-cdup.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >fribidi_log2vis</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="funcref.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ftp_cdup</TD ></TR ></TABLE ></DIV ></BODY ></HTML >