media_handle_upload


media_handle_upload ( $file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false ) )

Parameters:
  • (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.
Returns:
  • (int|WP_Error) ID of the attachment or a WP_Error object on failure.
Defined at:

Description

Save a file submitted from a POST request and create an attachment post for it.

Related Functions

media_handle_sideload, wp_handle_upload, _wp_handle_upload, wp_import_handle_upload, media_upload_tabs

Top Google Results

User discussions

wpseek mobile