Skip to content

Commit 92673cc

Browse files
saundefinedmumumucmb69
authored
[PHP 8.1] Documentation for full_path entry of $_FILES (#1130)
Co-authored-by: Yoshinari Takaoka <[email protected]> Co-authored-by: Christoph M. Becker <[email protected]>
1 parent 64a905b commit 92673cc

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

features/file-upload.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@
132132
</para>
133133
</listitem>
134134
</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>
135144
</variablelist>
136145
</para>
137146

@@ -462,6 +471,42 @@ foreach ($_FILES["pictures"]["error"] as $key => $error) {
462471
try to upload more files in one request than this limit.
463472
</simpara>
464473
</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>
465510
</sect1>
466511

467512
<sect1 xml:id="features.file-upload.put-method">

0 commit comments

Comments
 (0)