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

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