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

Description

Saves 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_file

Top Google Results

User discussions

wpseek mobile