登录  /  注册
有没有大佬遇到修改页面 不修改图片 提交后图片没了
-wy
-wy 2018-12-26 17:59:02
[PHP讨论组]

    public function edit(){
        $Article=D('Article');
        $Articler=$Article->find(I('id'));
        $this->assign('Articler',$Articler);
        if(IS_POST){
            $date['id']=I('id');
            $date['title']=I('title');
            $date['desc']=I('desc');                        //判断是否有POST方式提交
            $date['pic']=I('pic');
            $date['content']=I('content');
            $date['cateid']=I('cateid');
            if($_FILES['pic']['tmp_name']!=''){
               $upload = new \Think\Upload();// 实例化上传类
               $upload->maxSize   =3145728 ;// 设置附件上传大小
               $upload->exts      =array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
               $upload->rootPath  ='./'; // 设置附件上传根目录
               $upload->savePath  ='./Uploads/'; // 设置附件上传(子)目录
               $info   =   $upload->uploadOne($_FILES['pic']);
               // 上传文件
               if(!$info) {// 上传错误提示错误信息
                    $this->error($upload->getError());
               }else{// 上传成功
                    $date['pic']=$info['savepath'].$info['savename'];
               }
                    
            }else{

            }
            if($Article->create($date)){
               if($Article->save()){
                $this->success("修改文章成功!",U('lst'),3);
            }else{
                $this->error('修改文章失败!','',3);
            }
            }else{
                $this->error($Article->getError());

            }
            return;
        }
        $cateres=D('cate')->select();
        $this->assign('cateres',$cateres);
        $this->display();
    }  


<tr>
                                <th><i class="require-red">*</i>缩略图:</th>
                                <td>
                                    <if condition="$Articler['pic'] neq ''">
                                    <img src="__ROOT__{$Articler.pic}" height="50">
                                    <else/>
                                    无缩略图
                                    </if>                                    
                                    <input id="pic" name="pic" size="50" value="{$Articler.pic}" type="file">
                                </td>
                            </tr>

-wy
-wy

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号