wp_handle_upload() WordPress Function
The wp_handle_upload() function is used to upload a file to a WordPress site. This function is typically used to upload images, but it can also be used to upload other types of files. The function takes a file object as an argument and returns an array of information about the uploaded file.
wp_handle_upload( array $file, array|false $overrides = false, string $time = null ) #
Wrapper for _wp_handle_upload().
Description
Passes the ‘wp_handle_upload’ 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_upload( &$file, $overrides = false, $time = null ) { /* * $_POST['action'] must be set and its value must equal $overrides['action'] * or this: */ $action = 'wp_handle_upload'; if ( isset( $overrides['action'] ) ) { $action = $overrides['action']; } return _wp_handle_upload( $file, $overrides, $time, $action ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |