zblog主题配置页面上传图片功能
上传图片功能效果如图:

main.php 编写上传表单
提交图片到save.php,同时发起get和post请求,通过get传递一个type值,以便save.php通过该值判断行为做出不同处理。通过post上传图片数据。
<div id="divMain2">
<?php if ($act == 'config') { ?>
<table id="form1" name="form1" width="100%" style="padding:0;margin:0;" cellspacing="0" cellpadding="0" class="tableBorder">
<tr>
<th width="30%"><p align="center">选项名称</p></th>
<th width="20%"><p align="center">当前图片</p></th>
<th width="50%"><p align="center">上传图片</p></th>
</tr>
<form enctype="multipart/form-data" method="post" action="save.php?type=logo">
<tr>
<td><p align="center">LOGO图片</p></td>
<td>
<p align="center"><a href="style/images/logo.png" target="_blank">
<img src="style/images/logo.png" height="40px"></a></p>
</td>
<td>
<p align="center">
<input name="logo" type="file"/>
<input name="" type="Submit" class="button" value="保存"/>
</p>
</td>
</tr>
</form>
</table>
</div>save.php 编写接收图片保存功能
<?php
require '../../../zb_system/function/c_system_base.php';
require '../../../zb_system/function/c_system_admin.php';
$zbp->Load();
$action='root';
if (!$zbp->CheckRights($action)) {$zbp->mokeError(6);die();}
if (!$zbp->CheckPlugin('dipper_pcqxw')) {$zbp->mokeError(48);die();}
if($_GET['type'] == 'logo' ){
global $zbp;
foreach ($_FILES as $key => $value) {
//判断上传是否成功
if (is_uploaded_file($_FILES[$key]['tmp_name'])) {
//获取本地图片上传到服务器上的临时位置
$tmp_name = $_FILES[$key]['tmp_name'];
//将图片从临时位置移动到图片目录
@move_uploaded_file($_FILES[$key]['tmp_name'], $zbp->usersdir . 'theme/dipper_pcqxw/style/images/logo.png');
}
}
$zbp->SetHint('good','修改成功');//提示信息
Redirect('main.php?act=config');//跳转页面
}