上传头像在本地正常,在linux服务器上总是报“文件上传保存错误-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

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

杨冬芳 2016-07-13 16:37:44 1418
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'))));
} 
}
Linux
分享到
取消 提交回答
全部回答(1)
  • 杨冬芳
    2019-07-17 19:55:46

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

    0 0
开发与运维
使用钉钉扫一扫加入圈子
+ 订阅

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程