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.
- (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 Optional. Overwrite some of the attachment.
- (array) overrides Optional. Override the wp_handle_upload() behavior.
- (int|WP_Error) ID of the attachment or a WP_Error object on failure.
- Introduced in WordPress: 2.5.0
- Deprecated in WordPress: —
Saves a file submitted from a POST request and create an attachment post for it.