日期:2014-05-17 浏览次数:20418 次
前台
<form action="__URL__/user_upimgs" method="post" enctype="multipart/form-data">
<table width="516" height="206" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="111" height="124">当前头像:</td>
<td width="370">
<img width="111" height="120" src="../__PUBLIC__/{$content.user_upimg}"/>
</td>
</tr>
<tr>
<td height="21">上传新头像:</td>
<td><input type="file" name="user_upimg"/>
<input type="hidden" name="users_id" value="<php>echo $_SESSION['user_id'];</php>"/>
<input type="submit" value="上传"/></td>
</tr>
<tr>
<td colspan="2">建议使用正方形的图片,支持jpg.gif格式的,100k以内</td>
</tr>
</table></form>
后台
function user_upimgs(){
import("ORG.Net.UploadFile");
$upload = new UploadFile();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->saveRule = uniqid;//
$upload->savePath = './Public/Uploads/';// 设置附件上传目录
if(!$upload->upload()) {// 上传错误提示错误信息
$this->error($upload->getErrorMsg());
&n