public function index() { if ($handle = opendir('./Public/myimage')) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { $picpath = './Public/myimage/' . $file; dothumb($picpath); D('Image')->add($file); } } } }
public function uploadpic() { if (I('post.uid') != null && I('post.form') != null) { session('uid', I('post.uid')); if (I('post.sex')) { session('user_sex', I('post.sex')); } $limit['uid'] = I('post.uid'); $limit['has_upload'] = 1; $res = M('User')->where($limit)->find(); if ($res) { session("has_upload", 1); } else { session("has_upload", 0); } } if (session('has_upload') == 0 && session('uid') != null) { $filename = dothumb($this->doupload()); D('Image')->addpic($filename); $where['uid'] = I('session.uid'); $save['phone'] = I('post.phone'); $save['has_upload'] = 1; session('has_upload', 1); M('User')->where($where)->save($save); $this->ajaxReturn(true); } else { $this->ajaxReturn(false); } /* if(($_FILES['photo']!=null) && (I('session.uid')!=null) && (I('session.has_upload')==0)){ //if(I('session.username')!=null) $filename = dothumb(doupload()); D('Image')->add($filename); $where['uid'] = I('session.uid'); $save['phone'] = I('post.phone'); M('User')->where($where)->save($save); $this->ajaxReturn('ccc'); }else{ $this->ajaxReturn("你已上传过照片!"); } */ //session('photo',$info); //var_dump($a); }