Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
4c8c24b4
Commit
4c8c24b4
authored
Dec 22, 2017
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除上一次上传的头像
parent
606b762d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
Member.php
application/api/controller/Member.php
+16
-14
No files found.
application/api/controller/Member.php
View file @
4c8c24b4
...
...
@@ -390,21 +390,23 @@ class Member extends Basic
$info
=
$file
->
validate
([
'size'
=>
512000
,
'ext'
=>
'jpg,png'
])
//限制500KB
->
move
(
$path
);
if
(
$info
){
$img_path
=
$info
->
getSaveName
();
//生成的图片路径
$static_path
=
$path
.
DS
.
$img_path
;
//生成图片的绝对路径
$image
=
\think\Image
::
open
(
$static_path
);
$image
->
thumb
(
500
,
500
)
->
save
(
$static_path
);
//生成缩略图
//更新用户信息
$user
=
new
Users
();
$user
->
update
([
'id'
=>
$this
->
userId
,
'user_pic'
=>
$img_path
]);
if
(
$this
->
userId
)
{
$user
=
new
Users
();
$user_data
=
$user
->
field
(
'user_pic'
)
->
where
(
'id'
,
$this
->
userId
)
->
find
();
@
unlink
(
$path
.
DS
.
$user_data
->
user_pic
);
//删除原来的图片
$img_path
=
$info
->
getSaveName
();
//生成的图片路径
$static_path
=
$path
.
DS
.
$img_path
;
//生成图片的绝对路径
$image
=
\think\Image
::
open
(
$static_path
);
$image
->
thumb
(
500
,
500
)
->
save
(
$static_path
);
//生成缩略图
//更新用户信息
$user_data
->
user_pic
=
$img_path
;
$user_data
->
save
();
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
'上传成功'
;
$data
[
'data'
]
=
[
'file_name'
=>
HEADERIMGURL
.
$img_path
];
}
$data
[
'status'
]
=
200
;
$data
[
'msg'
]
=
'上传成功'
;
$data
[
'data'
]
=
[
'file_name'
=>
HEADERIMGURL
.
$img_path
];
}
else
{
// 上传失败获取错误信息
$data
[
'msg'
]
=
$file
->
getError
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment