admin管理员组文章数量:1026989
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.
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.
本文标签: phpUploading files using the Settings API
版权声明:本文标题:php - Uploading files using the Settings API 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745667195a2162244.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论