Uploading array of files (bug #32212)

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@181521 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2005-03-07 10:34:32 +00:00
parent df831bd377
commit 1b76ab3a6a

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.83 $ -->
<!-- $Revision: 1.84 $ -->
<chapter id="features.file-upload">
<title>Handling file uploads</title>
@ -212,6 +212,38 @@ print "</pre>";
The file will be deleted from the temporary directory at the end
of the request if it has not been moved away or renamed.
</simpara>
<example>
<title>Uploading array of files</title>
<para>
PHP supports <link linkend="faq.html.arrays">HTML array feature</link>
even with files.
</para>
<programlisting role="html">
<![CDATA[
<form action="" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="file" name="pictures[]" />
<input type="submit" value="Send" />
</p>
</form>
]]>
</programlisting>
<programlisting role="php">
<![CDATA[
<?php
foreach ($_FILES["pictures"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "data/$name");
}
}
?>
]]>
</programlisting>
</example>
</sect1>
<sect1 id="features.file-upload.errors">