Skip to content

[PHP 8.1] Documentation for full_path entry of $_FILES #1130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions features/file-upload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>$_FILES['userfile']['full_path']</varname></term>
<listitem>
<para>
The full path as submitted by the browser.
Available as of PHP 8.1.0.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>

Expand Down Expand Up @@ -462,6 +471,37 @@ foreach ($_FILES["pictures"]["error"] as $key => $error) {
try to upload more files in one request than this limit.
</simpara>
</warning>
<para>
<example>
<title>Uploading an entire directory</title>
<simpara>
In HTML file upload fields, it is possible to upload an entire directory with the <literal>webkitdirectory</literal> attribute.
This feature is supported in most modern browsers.
</simpara>
<simpara>
With the <literal>full_path</literal> information, it is possible to store the relative paths,
or reconstruct the same directory in the server.
</simpara>
<programlisting role="html">
<![CDATA[
<form action="file-upload.php" method="post" enctype="multipart/form-data">
Send this directory:<br />
<input name="userfile[]" type="file" webkitdirectory multiple />
<input type="submit" value="Send files" />
</form>
]]>
</programlisting>
</example>

<warning>
<simpara>
PHP only parses the relative path information submitted by the browser/user-agent,
and passes that information to the <varname>$_FILES</varname> array.
There is no guarantee that the values in the <literal>full_path</literal> array contains a real directory structure,
and the PHP applications must not trust this information.
</simpara>
</warning>
</para>
</sect1>

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