wp_handle_upload

函数
wp_handle_upload ( $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_uploadwp_handle_sideloadwp_import_handle_uploadmedia_handle_uploadwp_get_upload_dir
引入
2.0.0
弃用
-

wp_handle_upload: 这个函数用来处理文件的上传。它接收一个上传文件数据的数组作为参数,并返回附件ID。

_wp_handle_upload()的封装器。

传递{@see ‘wp_handle_upload’}动作。

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 );
}

常见问题

FAQs
查看更多 >