首页 WordPress函数大全 media_handle_upload()

media_handle_upload()

2020-05-02 / 5687阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

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

保存从POST请求提交的文件,并为其创建附件帖子。

描述

参数

$file_id

(string)
(Required)
Index of the $_FILES array that the file was sent. Required.

$post_id

(int)
(Required)
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.

$post_data

(array)
(Optional)
Overwrite some of the attachment. Optional.

Default value: array()

$overrides

(array)
(Optional)
Override the wp_handle_upload() behavior. Optional.

Default value: array('test_form' => false)

返回

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

大家谈论
    我的见解