On this page
wp_handle_sideload( array $file, array|false $overrides = false, string $time = null ): array
Wrapper for _wp_handle_upload() .
Description
Passes the ‘wp_handle_sideload’ action.
See also
Parameters
$filearray Required-
Reference to a single element of
$_FILES.
Call the function once for each uploaded file.
See _wp_handle_upload() for accepted values.More Arguments from _wp_handle_upload( ... $file )
Reference to a single element from$_FILES. Call the function once for each uploaded file.
namestringThe original name of the file on the client machine.typestringThe mime type of the file, if the browser provided this information.tmp_namestringThe temporary filename of the file in which the uploaded file was stored on the server.sizeintThe size, in bytes, of the uploaded file.errorintThe error code associated with this file upload.
$overridesarray|false Optional-
An associative array of names => values to override default variables.
See _wp_handle_upload() for accepted values.More Arguments from _wp_handle_upload( ... $overrides )
An array of override parameters for this file, or boolean false if none are provided.
upload_error_handlercallableFunction to call when there is an error during the upload process.
@see wp_handle_upload_error() .unique_filename_callbackcallableFunction to call when determining a unique file name for the file.
@see wp_unique_filename() .upload_error_stringsstring[]The strings that describe the error indicated in$_FILES[{form field}]['error'].test_formboolWhether to test that the$_POST['action']parameter is as expected.test_sizeboolWhether to test that the file size is greater than zero bytes.test_typeboolWhether to test that the mime type of the file is as expected.mimesstring[]Array of allowed mime types keyed by their file extension regex.
Default:
false $timestring Optional-
Time formatted in
'yyyy/mm'.Default:
null
Return
array See _wp_handle_upload() for return value.
Source
File: wp-admin/includes/file.php. View all references
function wp_handle_sideload( &$file, $overrides = false, $time = null ) {
/*
* $_POST['action'] must be set and its value must equal $overrides['action']
* or this:
*/
$action = 'wp_handle_sideload';
if ( isset( $overrides['action'] ) ) {
$action = $overrides['action'];
}
return _wp_handle_upload( $file, $overrides, $time, $action );
}
Related
Uses
| Uses | Description |
|---|---|
| _wp_handle_upload() wp-admin/includes/file.php | Handles PHP uploads in WordPress. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Attachments_Controller::upload_from_data() wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php | Handles an upload via raw POST data. |
| media_handle_sideload() wp-admin/includes/media.php | Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload() . |
Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_handle_sideload