最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Uploading files using the Settings API

programmeradmin2浏览0评论

I've used the Settings API in the past to output text inputs and checkboxes but am unsure if I can use file inputs.

My add_settings_field() is:

add_settings_field( '1', 'File 1', array( $this, 'my_callback' ), 'files', 'files' );

My callback function:

public function my_callback() {     
    echo '<input type="file" name="file" />';
}

I assume the next step is to handle the image upload. My problem is how do I do this using the Settings API? I am aware I can set a callback function as the 3rd parameter in register_setting() so my guess is I can use wp_handle_upload() in that callback. I'm looking for some guidance or confirmation that this is the approach I should take. Thanks in advance.

发布评论

评论列表(0)

  1. 暂无评论