Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > 05cd670d8a02b2b4a0ffb1756f2e8308 > files > 12149

php-manual-zh-5.2.4-1mdv2008.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>FTP 函数</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="PHP 手册"
HREF="index.html"><LINK
REL="UP"
TITLE="函数参考"
HREF="funcref.html"><LINK
REL="PREVIOUS"
TITLE="fbsql_warnings"
HREF="function.fbsql-warnings.html"><LINK
REL="NEXT"
TITLE="ftp_alloc"
HREF="function.ftp-alloc.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=UTF-8"></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 手册</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.fbsql-warnings.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ftp-alloc.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="reference"
><A
NAME="ref.ftp"
></A
><DIV
CLASS="TITLEPAGE"
><H1
CLASS="title"
>XLVI. FTP 函数</H1
><DIV
CLASS="PARTINTRO"
><A
NAME="AEN61094"
></A
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="ftp.intro"
>简介</A
></H1
><P
>&#13;    FTP 函数可以帮助实现客户机与服务器之间标准文件传送协议(FTP)的规范进行文件传送。FTP
    的详细定义参见 <A
HREF="http://www.faqs.org/rfcs/rfc959"
TARGET="_top"
>http://www.faqs.org/rfcs/rfc959</A
>。此扩展库用来使运行的脚本对
    FTP 服务器进行广泛的控制。如果只想在一个
    FTP 服务器上读写文件,考虑使用<A
HREF="ref.filesystem.html"
>文件系统函数</A
>中的
    <A
HREF="wrappers.ftp.html"
><TT
CLASS="literal"
>ftp://</TT
> wrapper</A
>,它提供了简单和更直观的接口。
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="ftp.requirements"
>需求</A
></H1
><P
>要编译本扩展模块无需外部库文件。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="ftp.installation"
>安装</A
></H1
><P
>&#13;  要使用这些 FTP 相关函数,在编译的时候请添加
  <CODE
CLASS="option"
>--enable-ftp</CODE
> 选项(PHP4或以上版本)或者
  <CODE
CLASS="option"
>--with-ftp</CODE
>(PHP3版本)。
 </P
><P
> <TT
CLASS="literal"
>PHP</TT
> 的 Windows
版本已经内置该扩展模块的支持。无需加载任何附加扩展库即可使用这些函数。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="ftp.configuration"
>运行时配置</A
></H1
><P
>本扩展模块在 <TT
CLASS="filename"
>php.ini</TT
> 中未定义任何配置选项。</P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="ftp.resources"
>资源类型</A
></H1
><P
>&#13;    在 FTP 模块中使用了一种资源类型,该资源类型为 FTP 的连接句柄,由函数
    <A
HREF="function.ftp-connect.html"
><B
CLASS="function"
>ftp_connect()</B
></A
> 或 <A
HREF="function.ftp-ssl-connect.html"
><B
CLASS="function"
>ftp_ssl_connect()</B
></A
> 产生。
   </P
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="ftp.constants"
>预定义常量</A
></H1
><P
>以下常量由本扩展模块定义,因此只有在本扩展模块被编译到
PHP 中,或者在运行时被动态加载后才有效。</P
><P
></P
><DIV
CLASS="variablelist"
><DL
><DT
><TT
CLASS="constant"
><B
>FTP_ASCII</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_TEXT</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_BINARY</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_IMAGE</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_TIMEOUT_SEC</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     参考函数 <A
HREF="function.ftp-set-option.html"
><B
CLASS="function"
>ftp_set_option()</B
></A
>。
    </P
></DD
></DL
></DIV
><P
>&#13;  下列变量在 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"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     参考函数 <A
HREF="function.ftp-set-option.html"
><B
CLASS="function"
>ftp_set_option()</B
></A
>。
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_AUTORESUME</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     为 GET 和 PUT 请求自动决定恢复和开始的位置
     (只能工作在 FTP_AUTOSEEK 打开的情况下)
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_FAILED</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     异步传输失败
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_FINISHED</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     异步传输成功
    </P
></DD
><DT
><TT
CLASS="constant"
><B
>FTP_MOREDATA</B
></TT
> 
    (<A
HREF="language.types.integer.html"
><B
CLASS="type"
>integer</B
></A
>)</DT
><DD
><P
>&#13;     异步传输是活动状态的
    </P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="ftp.examples"
>范例</A
></H1
><P
>&#13;    <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN61192"
></A
><P
><B
>例 1. FTP 例子</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><code><font color="#000000">
<font color="#0000BB">&lt;?php<br /></font><font color="#FF8000">// set up basic connection<br /></font><font color="#0000BB">$conn_id </font><font color="#007700">= </font><font color="#0000BB">ftp_connect</font><font color="#007700">(</font><font color="#0000BB">$ftp_server</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// login with username and password<br /></font><font color="#0000BB">$login_result </font><font color="#007700">= </font><font color="#0000BB">ftp_login</font><font color="#007700">(</font><font color="#0000BB">$conn_id</font><font color="#007700">, </font><font color="#0000BB">$ftp_user_name</font><font color="#007700">, </font><font color="#0000BB">$ftp_user_pass</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// check connection<br /></font><font color="#007700">if ((!</font><font color="#0000BB">$conn_id</font><font color="#007700">) || (!</font><font color="#0000BB">$login_result</font><font color="#007700">)) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"FTP connection has failed!"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Attempted to connect to $ftp_server for user $ftp_user_name"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Connected to $ftp_server, for user $ftp_user_name"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br /></font><font color="#FF8000">// upload the file<br /></font><font color="#0000BB">$upload </font><font color="#007700">= </font><font color="#0000BB">ftp_put</font><font color="#007700">(</font><font color="#0000BB">$conn_id</font><font color="#007700">, </font><font color="#0000BB">$destination_file</font><font color="#007700">, </font><font color="#0000BB">$source_file</font><font color="#007700">, </font><font color="#0000BB">FTP_BINARY</font><font color="#007700">);<br /><br /></font><font color="#FF8000">// check upload status<br /></font><font color="#007700">if (!</font><font color="#0000BB">$upload</font><font color="#007700">) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"FTP upload has failed!"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;} else {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo </font><font color="#DD0000">"Uploaded $source_file to $ftp_server as $destination_file"</font><font color="#007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br /></font><font color="#FF8000">// close the FTP stream<br /></font><font color="#0000BB">ftp_close</font><font color="#007700">(</font><font color="#0000BB">$conn_id</font><font color="#007700">);<br /></font><font color="#0000BB">?&gt;</font>
</font>
</code></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
   </P
></DIV
></DIV
><DIV
CLASS="TOC"
><DL
><DT
><B
>目录</B
></DT
><DT
><A
HREF="function.ftp-alloc.html"
>ftp_alloc</A
>&nbsp;--&nbsp;Allocates space for a file to be uploaded</DT
><DT
><A
HREF="function.ftp-cdup.html"
>ftp_cdup</A
>&nbsp;--&nbsp;切换到当前目录的父目录</DT
><DT
><A
HREF="function.ftp-chdir.html"
>ftp_chdir</A
>&nbsp;--&nbsp;在 FTP 服务器上改变当前目录</DT
><DT
><A
HREF="function.ftp-chmod.html"
>ftp_chmod</A
>&nbsp;--&nbsp;Set permissions on a file via FTP</DT
><DT
><A
HREF="function.ftp-close.html"
>ftp_close</A
>&nbsp;--&nbsp;关闭一个 FTP 连接</DT
><DT
><A
HREF="function.ftp-connect.html"
>ftp_connect</A
>&nbsp;--&nbsp;建立一个新的 FTP 连接</DT
><DT
><A
HREF="function.ftp-delete.html"
>ftp_delete</A
>&nbsp;--&nbsp;删除 FTP 服务器上的一个文件</DT
><DT
><A
HREF="function.ftp-exec.html"
>ftp_exec</A
>&nbsp;--&nbsp;请求运行一条 FTP 命令</DT
><DT
><A
HREF="function.ftp-fget.html"
>ftp_fget</A
>&nbsp;--&nbsp;从 FTP 服务器上下载一个文件并保存到本地一个已经打开的文件中</DT
><DT
><A
HREF="function.ftp-fput.html"
>ftp_fput</A
>&nbsp;--&nbsp;上传一个已经打开的文件到 FTP 服务器</DT
><DT
><A
HREF="function.ftp-get-option.html"
>ftp_get_option</A
>&nbsp;--&nbsp;返回当前 FTP 连接的各种不同的选项设置</DT
><DT
><A
HREF="function.ftp-get.html"
>ftp_get</A
>&nbsp;--&nbsp;从 FTP 服务器上下载一个文件</DT
><DT
><A
HREF="function.ftp-login.html"
>ftp_login</A
>&nbsp;--&nbsp;登录 FTP 服务器</DT
><DT
><A
HREF="function.ftp-mdtm.html"
>ftp_mdtm</A
>&nbsp;--&nbsp;返回指定文件的最后修改时间</DT
><DT
><A
HREF="function.ftp-mkdir.html"
>ftp_mkdir</A
>&nbsp;--&nbsp;建立新目录</DT
><DT
><A
HREF="function.ftp-nb-continue.html"
>ftp_nb_continue</A
>&nbsp;--&nbsp;连续获取/发送文件(non-blocking)</DT
><DT
><A
HREF="function.ftp-nb-fget.html"
>ftp_nb_fget</A
>&nbsp;--&nbsp;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
>&nbsp;--&nbsp;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
>&nbsp;--&nbsp;从 FTP 服务器上获取文件并写入本地文件(non-blocking)</DT
><DT
><A
HREF="function.ftp-nb-put.html"
>ftp_nb_put</A
>&nbsp;--&nbsp;存储一个文件至 FTP 服务器(non-blocking)</DT
><DT
><A
HREF="function.ftp-nlist.html"
>ftp_nlist</A
>&nbsp;--&nbsp;返回给定目录的文件列表</DT
><DT
><A
HREF="function.ftp-pasv.html"
>ftp_pasv</A
>&nbsp;--&nbsp;返回当前 FTP 被动模式是否打开</DT
><DT
><A
HREF="function.ftp-put.html"
>ftp_put</A
>&nbsp;--&nbsp;上传文件到 FTP 服务器</DT
><DT
><A
HREF="function.ftp-pwd.html"
>ftp_pwd</A
>&nbsp;--&nbsp;返回当前目录名</DT
><DT
><A
HREF="function.ftp-quit.html"
>ftp_quit</A
>&nbsp;--&nbsp;<A
HREF="function.ftp-close.html"
><B
CLASS="function"
>ftp_close()</B
></A
> 的别名</DT
><DT
><A
HREF="function.ftp-raw.html"
>ftp_raw</A
>&nbsp;--&nbsp;Sends an arbitrary command to an FTP server</DT
><DT
><A
HREF="function.ftp-rawlist.html"
>ftp_rawlist</A
>&nbsp;--&nbsp;返回指定目录下文件的详细列表</DT
><DT
><A
HREF="function.ftp-rename.html"
>ftp_rename</A
>&nbsp;--&nbsp;更改 FTP 服务器上的文件或目录名</DT
><DT
><A
HREF="function.ftp-rmdir.html"
>ftp_rmdir</A
>&nbsp;--&nbsp;删除一个目录</DT
><DT
><A
HREF="function.ftp-set-option.html"
>ftp_set_option</A
>&nbsp;--&nbsp;设置各种 FTP 运行时选项</DT
><DT
><A
HREF="function.ftp-site.html"
>ftp_site</A
>&nbsp;--&nbsp;向服务器发送 SITE 命令</DT
><DT
><A
HREF="function.ftp-size.html"
>ftp_size</A
>&nbsp;--&nbsp;返回指定文件的大小</DT
><DT
><A
HREF="function.ftp-ssl-connect.html"
>ftp_ssl_connect</A
>&nbsp;--&nbsp;Opens an Secure SSL-FTP connection</DT
><DT
><A
HREF="function.ftp-systype.html"
>ftp_systype</A
>&nbsp;--&nbsp;返回远程 FTP 服务器的系统类型</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.fbsql-warnings.html"
ACCESSKEY="P"
>上一页</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起始页</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ftp-alloc.html"
ACCESSKEY="N"
>下一页</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>fbsql_warnings</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="funcref.html"
ACCESSKEY="U"
>上一级</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>ftp_alloc</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>