<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/features.file-upload.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'features.file-upload.multiple.php',
    1 => 'Uploading multiple files',
    2 => 'Uploading multiple files',
  ),
  'up' => 
  array (
    0 => 'features.file-upload.php',
    1 => 'Handling file uploads',
  ),
  'prev' => 
  array (
    0 => 'features.file-upload.common-pitfalls.php',
    1 => 'Common Pitfalls',
  ),
  'next' => 
  array (
    0 => 'features.file-upload.put-method.php',
    1 => 'PUT method support',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'features/file-upload.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="features.file-upload.multiple" class="sect1">
   <h2 class="title">Uploading multiple files</h2>
   <p class="simpara">
    Multiple files can be uploaded using different
    <code class="literal">name</code> for <code class="literal">input</code>.
   </p>
   <p class="simpara">
    It is also possible to upload multiple files simultaneously and
    have the information organized automatically in arrays for you. To
    do so, you need to use the same array submission syntax in the
    HTML form as you do with multiple selects and checkboxes:
   </p>
   <p class="para">
    <div class="example" id="example-1">
     <p><strong>Приклад #1 Uploading multiple files</strong></p>
     <div class="example-contents">
<div class="htmlcode"><pre class="htmlcode">&lt;form action=&quot;file-upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
  Send these files:&lt;br /&gt;
  &lt;input name=&quot;userfile[]&quot; type=&quot;file&quot; /&gt;&lt;br /&gt;
  &lt;input name=&quot;userfile[]&quot; type=&quot;file&quot; /&gt;&lt;br /&gt;
  &lt;input type=&quot;submit&quot; value=&quot;Send files&quot; /&gt;
&lt;/form&gt;</pre>
</div>
     </div>

    </div>
   </p>
   <p class="simpara">
    When the above form is submitted, the arrays
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']</a></var>,
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['name']</a></var>, and
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['size']</a></var> will be
    initialized.
   </p>
   <p class="simpara">
    For instance, assume that the filenames
    <var class="filename">/home/test/review.html</var> and
    <var class="filename">/home/test/xwp.out</var> are submitted.  In this
    case, <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['name'][0]</a></var>
    would contain the value <var class="filename">review.html</var>, and
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['name'][1]</a></var> would
    contain the value <var class="filename">xwp.out</var>. Similarly,
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['size'][0]</a></var> would
    contain <var class="filename">review.html</var>&#039;s file size, and so forth.
   </p>
   <p class="simpara">
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['name'][0]</a></var>,
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['tmp_name'][0]</a></var>,
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['size'][0]</a></var>, and
    <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES['userfile']['type'][0]</a></var> are
    also set.
   </p>
   <div class="warning"><strong class="warning">Увага</strong>
    <p class="simpara">
     The
     <a href="ini.core.php#ini.max-file-uploads" class="link">max_file_uploads</a>
     configuration setting acts as a limit on the number of files that can be
     uploaded in one request. You will need to ensure that your form does not
     try to upload more files in one request than this limit.
    </p>
   </div>
   <p class="para">
    <div class="example" id="example-2">
     <p><strong>Приклад #2 Uploading an entire directory</strong></p>
     <div class="example-contents"><p>
      In HTML file upload fields, it is possible to upload an entire directory with the <code class="literal">webkitdirectory</code> attribute.
      This feature is supported in most modern browsers.
     </p></div>
     <div class="example-contents"><p>
      With the <code class="literal">full_path</code> information, it is possible to store the relative paths,
      or reconstruct the same directory in the server.
     </p></div>
     <div class="example-contents">
<div class="htmlcode"><pre class="htmlcode">&lt;form action=&quot;file-upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
  Send this directory:&lt;br /&gt;
  &lt;input name=&quot;userfile[]&quot; type=&quot;file&quot; webkitdirectory multiple /&gt;
  &lt;input type=&quot;submit&quot; value=&quot;Send files&quot; /&gt;
&lt;/form&gt;</pre>
</div>
     </div>

    </div>

    <div class="warning"><strong class="warning">Увага</strong>
     <p class="simpara">
      The <code class="literal">webkitdirectory</code> attribute is non-standard and is not on a standards track.
      Do not use it on production sites facing the Web: it will not work for every user.
      There may also be large incompatibilities between implementations and the behavior may change in the future.
     </p>
     <p class="simpara">
      PHP only parses the relative path information submitted by the browser/user-agent,
      and passes that information to the <var class="varname"><a href="reserved.variables.files.php" class="classname">$_FILES</a></var> array.
      There is no guarantee that the values in the <code class="literal">full_path</code> array contains a real directory structure,
      and the PHP application must not trust this information.
     </p>
    </div>
   </p>
  </div><?php manual_footer($setup); ?>