切换导航条
此项目
正在载入...
登录
何书鹏
/
recruit
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
4 years ago
提交
541bbb38aa9a7a7fbfaa83a8e1936cb8074785a8
1 个父辈
26bc4b4d
1 个管道 的构建
通过
耗费 4 秒
高效判断远程图片是否存在
变更
2
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
29 行增加
和
1 行删除
application/api/common.php
application/api/controller/User.php
application/api/common.php
查看文件 @
541bbb3
...
...
@@ -44,4 +44,32 @@ function createRoundImg($imgpath) {
header
(
"content-type:image/png"
);
imagepng
(
$image
,
$imgpath
);
imagedestroy
(
$image
);
}
/**
* 高效判断远程图片是否存在
*/
function
remoteImageExist
(
$url
)
{
// $exif_imagetype = [
// 1 => 'GIF',
// 2 => 'JPG',
// 3 => 'PNG',
// 4 => 'SWF',
// 5 => 'PSD',
// 6 => 'BMP',
// 7 => 'TIFF(intel byte order)',
// 8 => 'TIFF(motorola byte order)',
// 9 => 'JPC',
// 10 => 'JP2',
// 11 => 'JPX',
// 12 => 'JB2',
// 13 => 'SWC',
// 14 => 'IFF',
// 15 => 'WBMP',
// 16 => 'XBM'
// ];
$isExsit
=
@
exif_imagetype
(
$url
);
if
(
$isExsit
===
false
)
return
false
;
return
in_array
(
$isExsit
,
[
1
,
2
,
3
])
?
true
:
false
;
}
\ No newline at end of file
...
...
application/api/controller/User.php
查看文件 @
541bbb3
...
...
@@ -681,7 +681,7 @@ class User extends Api
{
$user
=
\app\api\model\User
::
get
(
$this
->
auth
->
id
);
empty
(
$user
[
'avatar'
])
&&
$this
->
error
(
'请先上传头像'
);
!
remoteImageExist
(
$user
[
'avatar'
])
&&
$this
->
error
(
'头像失效,请更新头像'
);
// 本地路径
$dir
=
'uploads/user'
;
if
(
!
file_exists
(
$dir
)){
...
...
请
注册
或
登录
后发表评论