wp_handle_sideload( array $file, array|false $overrides = false, string $time = null )
Wrapper for _wp_handle_upload().
Contents
Description
Passes the ‘wp_handle_sideload’ action.
See also
Parameters
- $file
-
(array) (Required) Reference to a single element of
$_FILES
. Call the function once for each uploaded file. See _wp_handle_upload() for accepted values. - $overrides
-
(array|false) (Optional) An associative array of names => values to override default variables. See _wp_handle_upload() for accepted values.
Default value: false
- $time
-
(string) (Optional) Time formatted in 'yyyy/mm'.
Default value: null
Return
(array) See _wp_handle_upload() for return value.
Source
File: wp-admin/includes/file.php
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 ); }
Expand full source code Collapse full source code View on Trac View on GitHub
Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example
This example uses download_url() to download the logo from wordpress.org and then moves it into the uploads directory.
Expand full source codeCollapse full source code
If you want to rename your uploaded file and you use a PHP class it is needed to do the callback like this:
Expand full source codeCollapse full source code
The returned array of file attributes includes values for these keys
url
type
file