ThinkCMF图片上传

前端使用content_addtop.js

<tr>
                <td><p class="pull-right">公司logo p>td>
                <td>
                    <div class="controls pull-left" style="margin-left: 0;">
                        
                        <div style="text-align: left;">
                            <input type='hidden' name='smeta[thumb]' id='thumb' value="{$smeta.thumb|default=''}">
                            <a href='javascript:void(0);'
                               onclick="flashupload('thumb_images', '附件上传','thumb',thumb_images,'1,jpg|jpeg|gif|png|bmp,1,,,1','','','');return false;">
                                <if condition="empty($data['logo'])">
                                    <img src="__ROOT__/statics/images/icon/upload-pic.png" id='thumb_preview'
                                         width='135' height='113' style='cursor:hand'/>
                                    <else/>
                                    <img src="{:sp_get_asset_upload_path($data['logo'])}" id='thumb_preview' width='135' height='113' style='cursor:hand'/>
                                if>
                            a>
                            
                            <input type="button" class="btn"
                                   onclick="$('#thumb_preview').attr('src','__ROOT__/statics/images/icon/upload-pic.png');$('#thumb').val('');$('#cancelpic').val('1');return false;"
                                   value="取消图片">
                        div>
                        <input type="hidden" name="cancelpic" id="cancelpic" value="0">
                    div>
                td>
            tr>
  public function edit_post(){
        if(IS_POST){
            $post_data = $_POST;
            $save_data['company_info'] = $post_data['name'];
            if(!empty($_POST['smeta']['thumb'])){
                $save_data['logo'] = sp_asset_relative_url($_POST['smeta']['thumb']);
            }elseif($_POST['cancelpic']=='1'){
                $save_data['logo']='';
            }

            $save_data['intro'] = $post_data['introduce'];
            $save_data['client_qq'] = $post_data['qq'];
            $save_data['direct_phone'] = $post_data['direct_tel'];
            $save_data['contact_phone'] = $post_data['tel'];
            $save_data['mobile'] = $post_data['mobile'];
            $save_data['email'] = $post_data['email'];
            $save_data['address'] = $post_data['address'];

            if(!empty($save_data['company_info'])&&
                !empty($save_data['direct_phone'])&&
                !empty($save_data['contact_phone'])&&
                !empty($save_data['mobile'])&&
                !empty($save_data['address'])){
                $result = $this->companyinfo_model->where('id=1')->save($save_data);
                if ($result !== false) {
                    $this->success("保存成功!");
                } else {
                    $this->error("保存失败!");
                }
            }else{
                $this->error("修改失败!有未填写的字段!");
            }
        }
    }

你可能感兴趣的:(学习笔记)