开发者社区> 问答> 正文

上传头像在本地正常,在linux服务器上总是报“文件上传保存错误

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'))));
} 
}

展开
收起
杨冬芳 2016-07-13 16:37:44 2430 0
1 条回答
写回答
取消 提交回答
  • IT从业

    猜测是没有创建文件的权限。

    2019-07-17 19:55:46
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS计算与存储分离架构实践 立即下载