public function uploadImage(){
if(!empty($_FILES)){
$upload = $this->upload;
$upload->maxSize = 3145728;
$upload->exts = array('jpg', 'jpeg', 'gif', 'png');
$upload->rootPath = 'Public/upload/headpic_osmg/';
dir_create($upload->rootPath); //根据日期创建文件夹
$info = $upload->uploadOne($_FILES['headpic']);
if(!$info){
exit(json_encode(array('status' => 'fail','msg' => $upload->getError())));
}else{
$param = I('post.');
if($param['student_id']){
if(!is_numeric($param['student_id'])){
returnInfoApi('0402','student_id数据类型错误');
}
}
$path = '/Public/upload/headpic_osmg/' . $info['savepath'].$info['savename'];
$bool = $this->StudentModel->uploadAvatar($path,$param['student_id']);
if($bool){
exit(json_encode(array('status' => 'success','path' => $path, 'msg' => C('L_NORMAL_SUCCESS'))));
}else{
exit(json_encode(array('status' => 'fail','msg' => C('L_NORMAL_FAIL'))));
}
}
}else{
exit(json_encode(array('status' => 'fail','msg' => C('L_NORMAL_FAIL'))));
}
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。