<!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="Manual do PHP" HREF="index.html"><LINK REL="UP" TITLE="Referência das Funções" 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" >Manual do PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.fbsql-warnings.html" ACCESSKEY="P" >Anterior</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" >Próxima</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="AEN56810" ></A ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.intro" >Introdução</A ></H1 ><P > As funções nesta extenção implementam o acesso de clientes para servidores de arquivos usando o File Transfer Protocol (FTP) como definido em <A HREF="http://www.faqs.org/rfcs/rfc959" TARGET="_top" >http://www.faqs.org/rfcs/rfc959</A >. Esta extenção permite acesso detalhado ao servidor FTP provendo um grande controle ao script. Se você quer somente ler ou escrever em um servidor FTP, você pode considerar o uso do <A HREF="wrappers.ftp.html" >wrapper <TT CLASS="literal" >ftp://</TT ></A > com <A HREF="ref.filesystem.html" >as funções do sistema de arquivo</A > o que prove um meio fácil e intuitivo. </P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.requirements" >Dependências</A ></H1 ><P >Nenhuma biblioteca externa é necessária para compilar esta extensão.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.installation" >Instalação</A ></H1 ><P > Para utilizar as funções de FTP na sua configuração do PHP, você deve adicionar a opção <CODE CLASS="option" >--enable-ftp</CODE > quando estiver instalando o PHP 4 ou posterior, <CODE CLASS="option" >--with-ftp</CODE > quando estiver instalando o PHP 3. </P ><P >A versão para Windows do <TT CLASS="literal" >PHP</TT > tem suporte embutido para esta extensão. Você não precisa carregar nenhuma extensão adicional para utilizar essas funções.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.configuration" >Configurações em execução</A ></H1 ><P >Esta extensão não define nenhum parâmetro de configuração no <TT CLASS="filename" >php.ini</TT >.</P ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.resources" >Tipos Resource</A ></H1 ><P > Este extenção usa um tipo resource, o qual é o identificador da conexão FTP, retornado por <A HREF="function.ftp-connect.html" ><B CLASS="function" >ftp_connect()</B ></A > ou <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" >Constantes pré-definidas</A ></H1 ><P > As contantes abaixo são definidas por esta extensão e somente estarão disponíveis quando a extensão foi compilada com o PHP ou carregada dinamicamente durante a execução. </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 ></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 ></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 ></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 ></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 > Veja <A HREF="function.ftp-set-option.html" ><B CLASS="function" >ftp_set_option()</B ></A > para maiores informações. </P ></DD ></DL ></DIV ><P > As seguintes constantes foram introduzidas no 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 > Veja <A HREF="function.ftp-set-option.html" ><B CLASS="function" >ftp_set_option()</B ></A > para maiores informações. </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 > Determina automaticamente a posição de reinício e início para requisições GET e PUT (funciona somente se FTP_AUTOSEEK estiver ativada) </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 > A transferência assincronoma falhou </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 > A transferência assincronoma terminou </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 > A transferência assincronoma ainda esta ativa </P ></DD ></DL ></DIV ></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="ftp.examples" >Exemplos</A ></H1 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN56908" ></A ><P ><B >Exemplo 1. Exemplo de FTP</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br /></font><font color="#FF8000">// Cria a conexão<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 com o nome de usuário e senha<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">// confere a conexão<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 /> echo </font><font color="#DD0000">"A conexão FTP falhou!"</font><font color="#007700">;<br /> echo </font><font color="#DD0000">"Tentou conectar ao servidor $ftp_server para o usuário $ftp_user_name"</font><font color="#007700">;<br /> exit;<br /> } else {<br /> echo </font><font color="#DD0000">"Conectaado ao servidor $ftp_server, para o usuário $ftp_user_name"</font><font color="#007700">;<br /> }<br /><br /></font><font color="#FF8000">// carrega o arquivo<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">// confere o upload do arquivo<br /></font><font color="#007700">if (!</font><font color="#0000BB">$upload</font><font color="#007700">) {<br /> echo </font><font color="#DD0000">"O upload FTP falhou!"</font><font color="#007700">;<br /> } else {<br /> echo </font><font color="#DD0000">"Carregado o arquivo $source_file no servidor $ftp_server como $destination_file"</font><font color="#007700">;<br /> }<br /><br /></font><font color="#FF8000">// fecha a conexão FTP<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">?></font> </font> </code></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="TOC" ><DL ><DT ><B >Índice</B ></DT ><DT ><A HREF="function.ftp-alloc.html" >ftp_alloc</A > -- Aloca espaço para um arquivo a ser enviado para o servidor (uploaded)</DT ><DT ><A HREF="function.ftp-cdup.html" >ftp_cdup</A > -- Muda para o diretório acima</DT ><DT ><A HREF="function.ftp-chdir.html" >ftp_chdir</A > -- Muda o diretório atual em um servidor FTP</DT ><DT ><A HREF="function.ftp-chmod.html" >ftp_chmod</A > -- Estabelece as permissões de um arquivo via FTP</DT ><DT ><A HREF="function.ftp-close.html" >ftp_close</A > -- Fecha uma conexão FTP</DT ><DT ><A HREF="function.ftp-connect.html" >ftp_connect</A > -- Abre uma conexão FTP</DT ><DT ><A HREF="function.ftp-delete.html" >ftp_delete</A > -- Exclui um arquivo no servidor FTP</DT ><DT ><A HREF="function.ftp-exec.html" >ftp_exec</A > -- Solicita a execução de um comando no servidor FTP</DT ><DT ><A HREF="function.ftp-fget.html" >ftp_fget</A > -- Copia um arquivo do servidor FTP e salva em um arquivo aberto</DT ><DT ><A HREF="function.ftp-fput.html" >ftp_fput</A > -- Envia um arquivo aberto para um servidor php</DT ><DT ><A HREF="function.ftp-get-option.html" >ftp_get_option</A > -- Obtém várias opções em tempo de execução da conexão FTP atual</DT ><DT ><A HREF="function.ftp-get.html" >ftp_get</A > -- Copia um arquivo do servidor FTP</DT ><DT ><A HREF="function.ftp-login.html" >ftp_login</A > -- Realiza o login em uma conexão FTP</DT ><DT ><A HREF="function.ftp-mdtm.html" >ftp_mdtm</A > -- Retorna a hora da ultima modificação no arquivo indicado</DT ><DT ><A HREF="function.ftp-mkdir.html" >ftp_mkdir</A > -- Cria um diretório</DT ><DT ><A HREF="function.ftp-nb-continue.html" >ftp_nb_continue</A > -- Continua a receber/enviar um arquivo (sem bloquear)</DT ><DT ><A HREF="function.ftp-nb-fget.html" >ftp_nb_fget</A > -- Obtém um arquivo de um servidor FTP e escreve-o para um arquivo aberto(sem bloquear)</DT ><DT ><A HREF="function.ftp-nb-fput.html" >ftp_nb_fput</A > -- Grava um arquivo a partir de um arquivo aberto no servidor FTP (sem bloquear)</DT ><DT ><A HREF="function.ftp-nb-get.html" >ftp_nb_get</A > -- Obtém um arquivo do servidor FTP e escreve-o em um arquivo local (sem bloquear)</DT ><DT ><A HREF="function.ftp-nb-put.html" >ftp_nb_put</A > -- Grava um arquivo no servidor FTP (sem bloquear)</DT ><DT ><A HREF="function.ftp-nlist.html" >ftp_nlist</A > -- Retorna a lista dos arquivos em um dado diretório</DT ><DT ><A HREF="function.ftp-pasv.html" >ftp_pasv</A > -- Muda o modo passivo em on(ligado) ou off(desligado)</DT ><DT ><A HREF="function.ftp-put.html" >ftp_put</A > -- Envia um arquivo para o servidor FTP</DT ><DT ><A HREF="function.ftp-pwd.html" >ftp_pwd</A > -- Retorna o nome do diretório atual</DT ><DT ><A HREF="function.ftp-quit.html" >ftp_quit</A > -- Sinônimo de <A HREF="function.ftp-close.html" ><B CLASS="function" >ftp_close()</B ></A ></DT ><DT ><A HREF="function.ftp-raw.html" >ftp_raw</A > -- Envia um comando arbritário para o servidor FTP</DT ><DT ><A HREF="function.ftp-rawlist.html" >ftp_rawlist</A > -- Retorna uma lista detalhada dos arquivos em um diretório</DT ><DT ><A HREF="function.ftp-rename.html" >ftp_rename</A > -- Renomeia um arquivo ou diretório no servidor FTP</DT ><DT ><A HREF="function.ftp-rmdir.html" >ftp_rmdir</A > -- Remove um diretório</DT ><DT ><A HREF="function.ftp-set-option.html" >ftp_set_option</A > -- Define opções diversas em tempo de execução</DT ><DT ><A HREF="function.ftp-site.html" >ftp_site</A > -- Envia o comando SITE para o servidor</DT ><DT ><A HREF="function.ftp-size.html" >ftp_size</A > -- Retorna o tamanho de um dado arquivo</DT ><DT ><A HREF="function.ftp-ssl-connect.html" >ftp_ssl_connect</A > -- Abre uma conexão SSL-FTP segura</DT ><DT ><A HREF="function.ftp-systype.html" >ftp_systype</A > -- Retorna o identificador do tipo do sistema do servidor FTP remoto</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" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Principal</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ftp-alloc.html" ACCESSKEY="N" >Próxima</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" >Acima</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >ftp_alloc</TD ></TR ></TABLE ></DIV ></BODY ></HTML >