diff --git a/module/user/lang/en.php b/module/user/lang/en.php index 05157fd229..4b3e8eb0a7 100644 --- a/module/user/lang/en.php +++ b/module/user/lang/en.php @@ -268,7 +268,7 @@ $lang->user->error->errorEmail = 'The account does not match the email. Pl $lang->user->error->emailSetting = 'No email is configured in the system. Contact the admin to reset the email.'; $lang->user->error->sendMailFail = 'Message sending failed, please try again!'; $lang->user->error->loginTimeoutTip = 'Login failed, please check if the proxy service is normal.'; -$lang->user->error->uploadAvatar = "The upload of your profile picture was unsuccessful. Kindly ensure that you're uploading a file of the appropriate image type."; +$lang->user->error->uploadAvatar = 'Failed to upload avatar. Please upload an image in %s format.'; $lang->user->contactFieldList['phone'] = $lang->user->phone; $lang->user->contactFieldList['mobile'] = $lang->user->mobile; diff --git a/module/user/lang/zh-cn.php b/module/user/lang/zh-cn.php index 1bcfa329be..76fb9064a7 100644 --- a/module/user/lang/zh-cn.php +++ b/module/user/lang/zh-cn.php @@ -268,7 +268,7 @@ $lang->user->error->errorEmail = '用户名和邮箱不匹配,请重新 $lang->user->error->emailSetting = '系统未配置发信邮箱,请联系管理员重置。'; $lang->user->error->sendMailFail = '邮件发送失败,请重试!'; $lang->user->error->loginTimeoutTip = '系统登录失败,请检查代理服务是否正常'; -$lang->user->error->uploadAvatar = '上传头像失败,请上传图片类型的文件。'; +$lang->user->error->uploadAvatar = '上传头像失败,请上传 %s 类型的图片。'; $lang->user->contactFieldList['phone'] = $lang->user->phone; $lang->user->contactFieldList['mobile'] = $lang->user->mobile; diff --git a/module/user/model.php b/module/user/model.php index 9b332e19f3..cacb425157 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -1462,7 +1462,8 @@ class userModel extends model $fileIdList = array_keys($uploadResult); $file = $this->file->getByID(end($fileIdList)); - if(!in_array($file->extension, array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) return array('result' => 'fail', 'message' => $this->lang->user->error->uploadAvatar); + $imageExtensions = $this->config->file->imageExtensions; + if(!in_array($file->extension, $imageExtensions)) return array('result' => 'fail', 'message' => sprintf($this->lang->user->error->uploadAvatar, implode(', ', $imageExtensions))); return array('result' => 'success', 'message' => '', 'fileID' => $file->id, 'locate' => helper::createLink('user', 'cropavatar', "image={$file->id}")); }