<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.ftp.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'pt_BR',
  ),
  'this' => 
  array (
    0 => 'function.ftp-chdir.php',
    1 => 'ftp_chdir',
    2 => 'Muda o diret&oacute;rio atual em um servidor FTP',
  ),
  'up' => 
  array (
    0 => 'ref.ftp.php',
    1 => 'Fun&ccedil;&otilde;es da extens&atilde;o FTP',
  ),
  'prev' => 
  array (
    0 => 'function.ftp-cdup.php',
    1 => 'ftp_cdup',
  ),
  'next' => 
  array (
    0 => 'function.ftp-chmod.php',
    1 => 'ftp_chmod',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'pt_BR',
    'path' => 'reference/ftp/functions/ftp-chdir.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.ftp-chdir" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ftp_chdir</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ftp_chdir</span> &mdash; <span class="dc-title">Muda o diretório atual em um servidor FTP</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.ftp-chdir-description">
  <h3 class="title">Descrição</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ftp_chdir</strong></span>(<span class="methodparam"><span class="type"><a href="class.ftp-connection.php" class="type FTP\Connection">FTP\Connection</a></span> <code class="parameter">$ftp</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$directory</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Muda o diretório atual para o especificado.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.ftp-chdir-parameters">
  <h3 class="title">Parâmetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">ftp</code></dt>
     <dd>
      <p class="para">Uma instância de <span class="classname"><a href="class.ftp-connection.php" class="classname">FTP\Connection</a></span>.</p>
     </dd>
    
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       O diretório de destino.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.ftp-chdir-returnvalues">
  <h3 class="title">Valor Retornado</h3>
  <p class="para">
   Retorna <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> em caso de sucesso ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> em caso de falha.
   Se houver falha ao mudar o diretório, o PHP também irá disparar um alerta.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.ftp-chdir-changelog">
  <h3 class="title">Registro de Alterações</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versão</th>
      <th>Descrição</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  O parâmetro <code class="parameter">ftp</code> agora espera uma instância de <span class="classname"><a href="class.ftp-connection.php" class="classname">FTP\Connection</a></span>;
  anteriormente, um <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> era esperado.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.ftp-chdir-examples">
  <h3 class="title">Exemplos</h3>
  <p class="para">
  <div class="example" id="example-1">
   <p><strong>Exemplo #1 Exemplo de <span class="function"><strong>ftp_chdir()</strong></span></strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// estabelece uma conexão básica<br /></span><span style="color: #0000BB">$ftp </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp_server</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// login com o nome de usuário e senha<br /></span><span style="color: #0000BB">$login_result </span><span style="color: #007700">= </span><span style="color: #0000BB">ftp_login</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">, </span><span style="color: #0000BB">$ftp_user_name</span><span style="color: #007700">, </span><span style="color: #0000BB">$ftp_user_pass</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// confere a conexão<br /></span><span style="color: #007700">if ((!</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">) || (!</span><span style="color: #0000BB">$login_result</span><span style="color: #007700">)) {<br />    die(</span><span style="color: #DD0000">"A conexão FTP falhou!"</span><span style="color: #007700">);<br />}<br /><br />echo </span><span style="color: #DD0000">"Diretório atual: " </span><span style="color: #007700">. </span><span style="color: #0000BB">ftp_pwd</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// tenta mudar para algumDiretorio<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">ftp_chdir</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">, </span><span style="color: #DD0000">"algumDiretorio"</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">"O diretório atual agora é: " </span><span style="color: #007700">. </span><span style="color: #0000BB">ftp_pwd</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">) . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">"Não foi possível mudar o diretório\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">// fecha a conexão<br /></span><span style="color: #0000BB">ftp_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ftp</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </p>
</div>

<div class="refsect1 seealso" id="refsect1-function.ftp-chdir-seealso">
 <h3 class="title">Veja Também</h3>
 <p class="para">
  <ul class="simplelist">
   <li><span class="function"><a href="function.ftp-cdup.php" class="function" rel="rdfs-seeAlso">ftp_cdup()</a> - Muda para o diret&oacute;rio acima</span></li>
   <li><span class="function"><a href="function.ftp-pwd.php" class="function" rel="rdfs-seeAlso">ftp_pwd()</a> - Retorna o nome do diret&oacute;rio atual</span></li>
  </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>