public function ajaxUploadAction()
 {
     $field = 'file';
     $fileExt = Upload::getFileExt($field);
     $fileSize = Upload::getFilesize($field);
     $tmpFile = Upload::getTmpName($field);
     if (!in_array($fileExt, array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) {
         $this->echoJson(1, '只允许jpg,jpeg,bmp,png,gif格式的图片!');
     }
     if ($fileSize > 102400) {
         $this->echoJson(1, '图片大小不能超过100KB!');
     }
     // 保存头像
     $cdnKey = Cdn::uploadLocalFile($tmpFile, $this->loginUserInfo['id'], $fileExt);
     UserCommonInterface::save(array('id' => $this->loginUserInfo['id'], 'head_img' => $cdnKey));
     // 删除原先的头像
     Cdn::delete($this->loginUserInfo['head_img']);
     $this->echoJson(0, 'Success!', array('src' => OjCommonHelper::getHeadUrl($cdnKey, $this->loginUserInfo['sex'])));
 }
示例#2
0
    <tbody>
        <?php 
foreach ($this->userList as $userInfo) {
    ?>
            <tr style="height: 69px;">
                <td class="tc"><?php 
    echo $rank++;
    ?>
</td>
                <td>
                    <a href="/user_my/?username=<?php 
    echo $userInfo['username'];
    ?>
">
                        <img style="border: 0;" src="//sta.hqoj.net/image/common/loading/loading04.gif" data-original="<?php 
    echo OjCommonHelper::getHeadUrl($userInfo['head_img'], $userInfo['sex']);
    ?>
" width="48px" height="48px" />
                    </a>
                </td>
                <td><a href="/user_my/?username=<?php 
    echo $userInfo['username'];
    ?>
"><?php 
    echo OjCommonHelper::getColorName($userInfo);
    ?>
</a></td>
                <td><?php 
    echo $userInfo['motto'];
    ?>
</td>
示例#3
0
<form id="form" class="widget-form">
    <div class="item">
        <label class="label w120">个性头像:</label>
        <img style="border: 1px solid #ddd;" id="pic-img" src="<?php 
echo OjCommonHelper::getHeadUrl($this->loginUserInfo['head_img'], $this->loginUserInfo['sex']);
?>
" width="100px" height="100px" />
        <a id="uploader-btn" href="#" return="false">[更换头像]</a>
        <span class="gray">&nbsp;只允许jpg,jpeg,bmp,png,gif格式,大小不超过100KB。</span>
    </div>
    <div class="item">
        <label class="label w120"><span class="red">* </span>昵称:</label>
        <input name="nickname" value="<?php 
echo $this->loginUserInfo['nickname'];
?>
" class="input w220" type="text" data-validation="length" data-validation-length="1-16" data-validation-error-msg="8个汉字或者16个英文字符以内" />
    </div>
    <div class="item">
        <label class="label w120">个性签名:</label>
        <input name="motto" value="<?php 
echo $this->loginUserInfo['motto'];
?>
" class="input w600" type="text" data-validation="length" data-validation-length="max100" />
    </div>
    <div class="item">
        <label class="w120 label"><span class="red">* </span>性别:</label>
        <label class="label"><input <?php 
echo $this->loginUserInfo['sex'] == 1 ? 'checked' : '';
?>
 value="1" name="sex" type="radio" class="radio" /> 男</label>
        <label class="label"><input <?php