WPDev.one
Core Function
View Source on Trac ↗

media_handle_sideload()

media_handle_sideload( mixed $file_array, mixed $post_id = 0, mixed $desc = null, mixed $post_data = array() )

Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload().

Parameters 1 required

Name / Type Description
$file_array
string[]

Array that represents a `$_FILES` upload array.

Required
$post_id
int

Optional. The post ID the media is associated with.

$desc
string

Optional. Description of the side-loaded file. Default null.

$post_data
array

Optional. Post data to override. Default empty array.

Return Value

((int)
| WP_Error) The ID of the attachment or a WP_Error on failure.

Function Information

Since Version
2.6.0
Source File
wp-admin/includes/media.php
Advertisement