想要让上传头像自动等比例压缩后自动删除源文件?求教~

浏览:457 发布日期:2017/03/24 分类:求助交流 关键字: 图片压缩
    function index() {
        $uid = $_GET['uid'];
        $where = array('uid'=>$uid);
        $users = M("User")->where($where)->find();
        $this->assign("users",$users);
        if ( empty($users) ) {
            exit('未查到该用户信息');
        }
        if ( IS_POST ) {
            if (!$_POST['phone']) {
                $this->error("请输入登录名");
                exit;
            }else {
                $map['phone'] = $_POST['phone'];
                $map['uid'] = array('neq',$_GET['uid']);
                $check = M("User")->where($map)->find();
                if (!empty($check)) {
                    $this->error("该用户名已存在!请重新输入");
                    exit;
                }
            }
            if (!$_POST['password']) {
                unset($_POST['password']);
            }else {
                $_POST['password'] = md5($_POST['password']);
            }
            import ( 'ORG.Net.UploadFile' );
            $upload = new UploadFile (); // 实例化上传类
            $upload->maxSize = 3145728; // 设置附件上传大小
            $upload->allowExts = array (
                    'jpg',
                    'gif',
                    'png',
                    'jpeg',
                    'xlsx',
                    'xls'
            ); // 设置附件上传类型
            $upload->savePath = './Public/Uploads/';
            $wx_info = array();
            $wx_info = json_decode($users['wx_info'],true);
            if (! $upload->upload ()) { // 上传错误提示错误信息
                $wx_info['nickname'] = $_POST['login'];
                $_POST['wx_info'] = json_encode($wx_info);
            } else { 
                $info = $upload->getUploadFileInfo ();
                $path = $upload->savePath.$info[0]['savename'];
                $wx_info['nickname'] = $_POST['login'];
                $wx_info['headimgurl'] = $path;
                $_POST['wx_info'] = json_encode($wx_info);
            }
            M("User")->where($where)->save($_POST);
            $this->success("保存成功!",U('App/Index/member',array("uid"=>$users['uid'])) );
            exit;
        }
        $this->display("./default/Index/member_index");
    }
最佳答案
评论( 相关
后面还有条评论,点击查看>>