vrana Mon Mar 7 05:34:34 2005 EDT
Modified files: /phpdoc/en/features file-upload.xml Log: Uploading array of files (bug #32212) http://cvs.php.net/diff.php/phpdoc/en/features/file-upload.xml?r1=1.83&r2=1.84&ty=u Index: phpdoc/en/features/file-upload.xml diff -u phpdoc/en/features/file-upload.xml:1.83 phpdoc/en/features/file-upload.xml:1.84 --- phpdoc/en/features/file-upload.xml:1.83 Sun Jan 23 15:04:34 2005 +++ phpdoc/en/features/file-upload.xml Mon Mar 7 05:34:32 2005 @@ -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 @@ 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">