downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/wrappers.ftp.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/wrappers.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'wrappers.ftp.php',
   
1 => 'FTP and FTPS',
  ),
 
'up' =>
  array (
   
0 => 'wrappers.php',
   
1 => 'List of Supported Protocols/Wrappers',
  ),
 
'prev' =>
  array (
   
0 => 'wrappers.http.php',
   
1 => 'HTTP and HTTPS',
  ),
 
'next' =>
  array (
   
0 => 'wrappers.php.php',
   
1 => 'PHP input/output streams',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="wrappers.ftp" class="section">
  <h2 class="title">FTP and FTPS</h2>
  <p class="simpara">PHP 4, PHP 5, PHP 6.  <var class="filename">ftps://</var> since PHP 4.3.0</p>

  <ul class="itemizedlist">
   <li class="listitem"><span class="simpara"><var class="filename">ftp://example.com/pub/file.txt</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">ftp://user:password@example.com/pub/file.txt</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">ftps://example.com/pub/file.txt</var></span></li>
   <li class="listitem"><span class="simpara"><var class="filename">ftps://user:password@example.com/pub/file.txt</var></span></li>
  </ul>

  <p class="simpara">
   Allows read access to existing files and creation of new files
   via FTP.  If the server does not support passive mode ftp, the
   connection will fail.
  </p>
  <p class="simpara">
   You can open files for either reading or writing, but not both
   simultaneously.  If the remote file already exists on the ftp
   server and you attempt to open it for writing but have not specified
   the context option <i>overwrite</i>, the connection
   will fail.  If you need to overwrite existing files over ftp,
   specify the <i>overwrite</i> option in the context
   and open the file for writing.  Alternatively, you can
   use the <a href="ref.ftp.php" class="link">FTP extension</a>.
  </p>
  <blockquote><p><b class="note">Note</b>:
   <b>Appending</b><br />
   <span class="simpara">
    As of PHP 5.0.0 files may be appended via the
    <i>ftp://</i> URL wrapper.  In prior versions, attempting
    to append to a file via <i>ftp://</i> will result in failure.
   </span>
  </p></blockquote>
  <p class="simpara">
   <var class="filename">ftps://</var> was introduced in PHP 4.3.0.
   It is the same as <var class="filename">ftp://</var>,
   but attempts to negotiate a secure connection with the ftp server.
   If the server does not support SSL, then the connection falls back
   to regular unencrypted ftp.
  </p>
  <blockquote><p><b class="note">Note</b>:
   <span class="simpara">FTPS is supported starting from PHP 4.3.0, if you
    have compiled in support for OpenSSL.
   </span>
  </p></blockquote>
  <p class="simpara">
   If you have set the <a href="filesystem.configuration.php#ini.from" class="link">from</a> directive
   in <var class="filename">php.ini</var>, then this value will be sent as the anonymous FTP
   password.
  </p>
  <p class="para">
   </p><table class="doctable table">
    <caption><b>Wrapper Summary</b></caption>
   
     <thead valign="middle">
      <tr valign="middle">
       <th>Attribute</th>
       <th>PHP 4</th>
       <th>PHP 5</th>
      </tr>

     </thead>

     <tbody valign="middle" class="tbody">
      <tr valign="middle">
       <td align="left">Restricted by <a href="filesystem.configuration.php#ini.allow-url-fopen" class="link">allow_url_fopen</a></td>
       <td align="left">Yes</td>
       <td align="left">Yes</td>
      </tr>

      <tr valign="middle">
       <td align="left">Allows Reading</td>
       <td align="left">Yes</td>
       <td align="left">Yes</td>
      </tr>

      <tr valign="middle">
       <td align="left">Allows Writing</td>
       <td align="left">Yes (new files only)</td>
       <td align="left">Yes (new files/existing files with <i><tt class="parameter">overwrite</tt></i>
)</td>
      </tr>

      <tr valign="middle">
       <td align="left">Allows Appending</td>
       <td align="left">No</td>
       <td align="left">Yes</td>
      </tr>

      <tr valign="middle">
       <td align="left">Allows Simultaneous Reading and Writing</td>
       <td align="left">No</td>
       <td align="left">No</td>
      </tr>

      <tr valign="middle">
       <td align="left">Supports <a href="function.stat.php" class="function">stat()</a></td>
       <td align="left">No</td>
       <td align="left">
        As of PHP 5.0.0: <a href="function.filesize.php" class="function">filesize()</a>,
        <a href="function.filetype.php" class="function">filetype()</a>, <a href="function.file-exists.php" class="function">file_exists()</a>,
        <a href="function.is-file.php" class="function">is_file()</a>, and <a href="function.is-dir.php" class="function">is_dir()</a> elements only.
        As of PHP 5.1.0: <a href="function.filemtime.php" class="function">filemtime()</a>.
       </td>
      </tr>

      <tr valign="middle">
       <td align="left">Supports <a href="function.unlink.php" class="function">unlink()</a></td>
       <td align="left">No</td>
       <td align="left">Yes</td>
      </tr>

      <tr valign="middle">
       <td align="left">Supports <a href="function.rename.php" class="function">rename()</a></td>
       <td align="left">No</td>
       <td align="left">Yes</td>
      </tr>

      <tr valign="middle">
       <td align="left">Supports <a href="function.mkdir.php" class="function">mkdir()</a></td>
       <td align="left">No</td>
       <td align="left">Yes</td>
      </tr>

      <tr valign="middle">
       <td align="left">Supports <a href="function.rmdir.php" class="function">rmdir()</a></td>
       <td align="left">No</td>
       <td align="left">Yes</td>
      </tr>

     </tbody>
   
   </table>
<p>
  </p>
 </div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites