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/features.file-upload.multiple.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'features.file-upload.multiple.php',
   
1 => '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',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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
    <i>name</i> for <i>input</i>.
   </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">
    </p><div class="example">
     <p><b>Example #1 Uploading multiple files</b></p>
     <div class="example-contents programlisting">
<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>
   <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 (as well as in <var class="varname">$HTTP_POST_FILES</var> for PHP versions prior
    to 4.1.0).
    When
    <a href="ini.core.php#ini.register-globals" class="link">register_globals</a> is on, globals for uploaded
    files are also initialized. Each of these will be a numerically
    indexed array of the appropriate values for the submitted files.
   </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><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites