wp_handle_sideload

Wrapper for _wp_handle_upload().

Description

(array) wp_handle_sideload( (array) &$file, (constant) $overrides = false, (null) $time = null ); 

Passes the action.

Returns (array)

On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).

Parameters (3)

0. $file (array) => &$file
An array similar to that of a PHP $_FILES POST array
1. $overrides — Optional. (constant) => false
An associative array of names=>values to override default variables. Default false.
2. $time — Optional. (null) => null
Time formatted in yyyy/mm.. Default null.

Usage

  1. if ( !function_exists( 'wp_handle_sideload' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/file.php'; 
  3.  
  4. // An array similar to that of a PHP `$_FILES` POST array 
  5. $file = array(); 
  6.  
  7. // Optional. An associative array of names=>values to override default 
  8. // variables. Default false. 
  9. $overrides = false; 
  10.  
  11. // Optional. Time formatted in 'yyyy/mm'. Default null. 
  12. $time = null; 
  13.  
  14. // NOTICE! Understand what this does before running. 
  15. $result = wp_handle_sideload($file, $overrides, $time); 
  16.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/file.php  
  1. function wp_handle_sideload( &$file, $overrides = false, $time = null ) { 
  2. /** 
  3. * $_POST['action'] must be set and its value must equal $overrides['action'] 
  4. * or this: 
  5. */ 
  6. $action = 'wp_handle_sideload'; 
  7. if ( isset( $overrides['action'] ) ) { 
  8. $action = $overrides['action']; 
  9. return _wp_handle_upload( $file, $overrides, $time, $action );