|
132 | 132 | </para>
|
133 | 133 | </listitem>
|
134 | 134 | </varlistentry>
|
| 135 | + <varlistentry> |
| 136 | + <term><varname>$_FILES['userfile']['full_path']</varname></term> |
| 137 | + <listitem> |
| 138 | + <para> |
| 139 | + The full path as submitted by the browser. This value does not always contain a real directory structure, and cannot be trusted. |
| 140 | + Available as of PHP 8.1.0. |
| 141 | + </para> |
| 142 | + </listitem> |
| 143 | + </varlistentry> |
135 | 144 | </variablelist>
|
136 | 145 | </para>
|
137 | 146 |
|
@@ -462,6 +471,42 @@ foreach ($_FILES["pictures"]["error"] as $key => $error) {
|
462 | 471 | try to upload more files in one request than this limit.
|
463 | 472 | </simpara>
|
464 | 473 | </warning>
|
| 474 | + <para> |
| 475 | + <example> |
| 476 | + <title>Uploading an entire directory</title> |
| 477 | + <simpara> |
| 478 | + In HTML file upload fields, it is possible to upload an entire directory with the <literal>webkitdirectory</literal> attribute. |
| 479 | + This feature is supported in most modern browsers. |
| 480 | + </simpara> |
| 481 | + <simpara> |
| 482 | + With the <literal>full_path</literal> information, it is possible to store the relative paths, |
| 483 | + or reconstruct the same directory in the server. |
| 484 | + </simpara> |
| 485 | + <programlisting role="html"> |
| 486 | +<![CDATA[ |
| 487 | +<form action="file-upload.php" method="post" enctype="multipart/form-data"> |
| 488 | + Send this directory:<br /> |
| 489 | + <input name="userfile[]" type="file" webkitdirectory multiple /> |
| 490 | + <input type="submit" value="Send files" /> |
| 491 | +</form> |
| 492 | +]]> |
| 493 | + </programlisting> |
| 494 | + </example> |
| 495 | + |
| 496 | + <warning> |
| 497 | + <simpara> |
| 498 | + The <literal>webkitdirectory</literal> attribute is non-standard and is not on a standards track. |
| 499 | + Do not use it on production sites facing the Web: it will not work for every user. |
| 500 | + There may also be large incompatibilities between implementations and the behavior may change in the future. |
| 501 | + </simpara> |
| 502 | + <simpara> |
| 503 | + PHP only parses the relative path information submitted by the browser/user-agent, |
| 504 | + and passes that information to the <varname>$_FILES</varname> array. |
| 505 | + There is no guarantee that the values in the <literal>full_path</literal> array contains a real directory structure, |
| 506 | + and the PHP application must not trust this information. |
| 507 | + </simpara> |
| 508 | + </warning> |
| 509 | + </para> |
465 | 510 | </sect1>
|
466 | 511 |
|
467 | 512 | <sect1 xml:id="features.file-upload.put-method">
|
|
0 commit comments