wp_handle_sideload

函式
wp_handle_sideload ( $file, $overrides = false, $time = null )
引數
  • (array) $file Reference to a single element of `$_FILES`. Call the function once for each uploaded file. See _wp_handle_upload() for accepted values.
    Required:
  • (array|false) $overrides Optional. An associative array of names => values to override default variables. Default false. See _wp_handle_upload() for accepted values.
    Required:
    Default: false
  • (string) $time Optional. Time formatted in 'yyyy/mm'. Default null.
    Required:
    Default: null
返回值
  • (array) See _wp_handle_upload() for return value.
相關
  • _wp_handle_upload()
定義位置
相關方法
wp_handle_uploadmedia_handle_sideload_wp_handle_uploadwp_embed_handler_videowp_import_handle_upload
引入
2.6.0
棄用
-

wp_handle_sideload: 這個函式用於處理檔案的側載。它接收一個側載檔案資料的陣列作為引數,並返回附件ID。

_wp_handle_upload()的封裝器。

傳遞{@see ‘wp_handle_sideload’}動作。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常見問題

FAQs
檢視更多 >