media_handle_upload ( $file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false ) )
- (string) $file_id Index of the `$_FILES` array that the file was sent. Required.
- (int) $post_id The post ID of a post to attach the media item to. Required, but can be set to 0, creating a media item that has no relationship to a post.
- (array) $post_data Overwrite some of the attachment. Optional.
- (array) $overrides Override the wp_handle_upload() behavior. Optional.
- (int|WP_Error) ID of the attachment or a WP_Error object on failure.
- Introduced in WordPress: 2.5.0
- Deprecated in WordPress: —
Save a file submitted from a POST request and create an attachment post for it.