<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.fdf-get-attachment" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>fdf_get_attachment</refname>
  <refpurpose>Extracts uploaded file embedded in the FDF</refpurpose>
 </refnamediv>
 
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>array</type><methodname>fdf_get_attachment</methodname>
   <methodparam><type>resource</type><parameter>fdf_document</parameter></methodparam>
   <methodparam><type>string</type><parameter>fieldname</parameter></methodparam>
   <methodparam><type>string</type><parameter>savepath</parameter></methodparam>
  </methodsynopsis>
  <para>
   Extracts a file uploaded by means of the "file selection" field
   <parameter>fieldname</parameter> and stores it under
   <parameter>savepath</parameter>. 
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>fdf_document</parameter></term>
     <listitem>
      <para>
       The FDF document handle, returned by <function>fdf_create</function>,
       <function>fdf_open</function> or <function>fdf_open_string</function>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>fieldname</parameter></term>
     <listitem>
      <para>
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>savepath</parameter></term>
     <listitem>
      <para>
       May be the name of a plain file or an existing directory in which the
       file is to be created under its original name. Any existing file under
       the same name will be overwritten.
      </para>
      <note>
       <para>
        There seems to be no other way to find out the original filename but
        to store the file using a directory as 
        <parameter>savepath</parameter> and check for the basename it was
        stored under.
       </para>
      </note>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   The returned array contains the following fields:
   <itemizedlist>
    <listitem>
     <simpara><parameter>path</parameter> - path were the file got stored</simpara>
    </listitem>
    <listitem>
     <simpara><parameter>size</parameter> - size of the stored file in bytes</simpara>
    </listitem>
    <listitem>
     <simpara><parameter>type</parameter> - mimetype if given in the FDF</simpara>
    </listitem>
   </itemizedlist>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Storing an uploaded file</title>
    <programlisting role="php">
<![CDATA[
<?php
  $fdf = fdf_open_string($HTTP_FDF_DATA);
  $data = fdf_get_attachment($fdf, "filename", "/tmpdir");
  echo "The uploaded file is stored in $data[path]";
?>
]]>
    </programlisting>
   </example>
  </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
-->
