Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0c310352
authored
Nov 19, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传图片
parent
1398eea4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
22 deletions
+5
-22
app/Api/Controllers/PharmacistController.php
+5
-22
No files found.
app/Api/Controllers/PharmacistController.php
View file @
0c310352
...
...
@@ -61,31 +61,14 @@ public function uploadCertificate(Request $request)
// 获取上传的图片
if
(
$request
->
hasFile
(
'image'
))
{
// 获取图片文件
$image
=
$request
->
file
(
'image'
);
// 生成唯一文件名
$fileName
=
time
()
.
'.'
.
$image
->
getClientOriginalExtension
();
// 保存图片到指定路径
$tempPath
=
$image
->
storeAs
(
'app/public'
,
$fileName
);
// 读取文件内容
$fileContent
=
file_get_contents
(
storage_path
(
'app/public/'
.
$fileName
));
// 上传到腾讯云
Storage
::
disk
(
'cos'
)
->
put
(
'license-images/'
.
$fileName
,
$fileContent
);
// 返回图片地址
$imageUrl
=
Storage
::
disk
(
'cos'
)
->
url
(
'license-images/'
.
$fileName
);
// 删除临时文件
unlink
(
storage_path
(
'app/public/'
.
$fileName
));
$path
=
Storage
::
putFile
(
'license-images'
,
$request
->
file
(
'image'
));
// 返回完整图片地址
$imageUrl
=
Storage
::
url
(
$path
);
return
$this
->
success
([
'
message'
=>
'ok'
,
'
url'
=>
$imageUrl
]);
return
$this
->
success
([
'
image_id'
=>
$path
,
'full_
url'
=>
$imageUrl
]);
}
else
{
return
$this
->
failed
(
'
图片上传失败
'
);
return
$this
->
failed
(
'
请上传图片~
'
);
}
}
...
...
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