mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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:
parent
df831bd377
commit
1b76ab3a6a
1 changed files with 33 additions and 1 deletions
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue