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'))));
}
}
![](https://profile-avatar.csdnimg.cn/7902456398434747b72cd7f721e66af0_qq20151.jpg!4)
上传头像在本地正常,在linux服务器上总是报“文件上传保存错误
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
悬赏问题
- ¥15 三分类机器学习模型可视化分析
- ¥15 本地测试网站127.0.0.1 已拒绝连接,如何解决?(标签-ubuntu)
- ¥50 Qt在release捕获异常并跟踪堆栈(有Demo,跑一下环境再回答)
- ¥30 python,LLM 文本提炼
- ¥15 关于将inet引入的相关问题
- ¥15 关于一个倒计时的操作和显示设计
- ¥15 提问STK的问题,哪位航天领域的同学会啊
- ¥15 苹果系统的mac m1芯片的笔记本使用ce修改器使用不了
- ¥15 单相逆变的电压电流双闭环中进行低通滤波PID算法改进
- ¥15 关于#java#的问题,请各位专家解答!