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’}动作。

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
查看更多 >