[wp-trac] [WordPress Trac] #38560: media_handle_upload() can't handle arrayed $_FILES
WordPress Trac
noreply at wordpress.org
Sat Oct 29 13:11:25 UTC 2016
#38560: media_handle_upload() can't handle arrayed $_FILES
--------------------------+-----------------------------
Reporter: kontur | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 4.6.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
When you have form code that references [several file
uploads](http://php.net/manual/en/features.file-upload.multiple.php) as
array, the media_handle_upload() function fails to handle this.
For example this:
{{{
<input type="file" name="documents[]">
<input type="file" name="documents[]">
}}}
Will result in a $_FILES array that's creates subarrays shaped like so:
{{{
$_FILES['userfile']['name'][0]
$_FILES['userfile']['name'][1]
$_FILES['userfile']['tmp_name'][0]
$_FILES['userfile']['tmp_name'][1]
$_FILES['userfile']['size'][0]
$_FILES['userfile']['size'][1]
$_FILES['userfile']['type'][0]
$_FILES['userfile']['type'][1]
}}}
This will fail when passed to media_handle_upload, since [the
implementation does not handle this array
structure](https://core.trac.wordpress.org/browser/tags/4.5.3/src/wp-
admin/includes/media.php#L281) nor is this documented.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38560>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list