文件上传不起作用,为什么?怎么能帮到我?文件不上传。
这是设置页面
function ag_products_theme_settings_page(){
?>
<div class="wrap">
<h1>AG Products</h1>
<form method="post" action="options.php" enctype="multipart/form-data">
<?php
settings_fields("section");
do_settings_sections("theme-options");
submit_button();
?>
</form>
</div>
<?php
}
这是显示徽标
的一部分function logo_display()
{
?>
<input type="file" name="logo" />
<?php echo get_option('logo');
?>
<?php
}
这是上传徽标的一部分
function handle_logo_upload()
{
if(!empty($_FILES["demo-file"]["tmp_name"]))
{
require_once( ABSPATH . 'wp-admin/includes/file.php' );
$urls = wp_handle_upload($_FILES["logo"], array('test_form' => false));
$temp = $urls['url'];
return $temp;
}
return $option;
}
这是寄存器
function ag_products_display_theme_panel_fields()
{
add_settings_section("section", "All Settings", null, "theme-options");
add_settings_field("logo", "Logo", "logo_display", "theme-options", "section");
register_setting("section", "logo", "handle_logo_upload");
}
add_action("admin_init", "ag_products_display_theme_panel_fields");