wp_handle_upload( array $file, array|false $overrides = false, string $time = null ): array
Wrapper for _wp_handle_upload() .
Contents
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.More Arguments from _wp_handle_upload( ... $file )
Reference to a single element from$_FILES
. Call the function once for each uploaded file.
name
stringThe original name of the file on the client machine.type
stringThe mime type of the file, if the browser provided this information.tmp_name
stringThe temporary filename of the file in which the uploaded file was stored on the server.size
intThe size, in bytes, of the uploaded file.error
intThe error code associated with this file upload.
-
$overrides
array|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_handler
callableunique_filename_callback
callableupload_error_strings
string[]The strings that describe the error indicated in$_FILES[{form field}]['error']
.test_form
boolWhether to test that the$_POST['action']
parameter is as expected.test_size
boolWhether to test that the file size is greater than zero bytes.test_type
boolWhether to test that the mime type of the file is as expected.mimes
string[]Array of allowed mime types keyed by their file extension regex.
Default:
false
-
$time
string 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_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 );
}
Changelog
Version | Description |
---|---|
2.0.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example