<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.ftp-alloc" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>ftp_alloc</refname>
  <refpurpose>Allocates space for a file to be uploaded</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>ftp_alloc</methodname>
   <methodparam><type>resource</type><parameter>ftp_stream</parameter></methodparam>
   <methodparam><type>int</type><parameter>filesize</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter role="reference">result</parameter></methodparam>
  </methodsynopsis>
  <para>
   Sends an <literal>ALLO</literal> command to the remote FTP server to 
   allocate space for a file to be uploaded.
  </para>
  <note>
   <para>
    Many FTP servers do not support this command.  These servers may return a failure 
    code (&false;) indicating the command is not supported or a success code (&true;)
    to indicate that pre-allocation is not necessary and the client should continue
    as though the operation were successful.  Because of this, it may be best to reserve
    this function for servers which explicitly require preallocation.
   </para>
  </note>
  <para>
  </para>
 </refsect1>
 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>ftp_stream</parameter></term>
     <listitem>
      <para>
       The link identifier of the FTP connection.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>filesize</parameter></term>
     <listitem>
      <para>
       The number of bytes to allocate.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>result</parameter></term>
     <listitem>
      <para>
       A textual representation of the servers response will be returned by 
       reference in <parameter>result</parameter> if a variable is provided.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>
 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>ftp_alloc</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php

$file = "/home/user/myfile";

// connect to the server
$conn_id = ftp_connect('ftp.example.com');
$login_result = ftp_login($conn_id, 'anonymous', 'user@example.com');

if (ftp_alloc($conn_id, filesize($file), $result)) {
  echo "Space successfully allocated on server.  Sending $file.\n";
  ftp_put($conn_id, '/incomming/myfile', $file, FTP_BINARY);
} else {
  echo "Unable to allocate space on server.  Server said: $result\n";
}

ftp_close($conn_id);

?>
]]>
    </programlisting>
   </example>
  </para>
 </refsect1>
 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>ftp_put</function></member>
    <member><function>ftp_fput</function></member>
   </simplelist>
  </para>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->