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
34f179db
authored
Nov 19, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
图片上传修改
parent
9cb8ff3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
app/Api/Controllers/DoctorController.php
+6
-2
app/Api/Controllers/PharmacistController.php
+5
-2
No files found.
app/Api/Controllers/DoctorController.php
View file @
34f179db
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
use
App\Models\User
;
use
App\Models\User
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Support\Facades\Storage
;
use
Illuminate\Support\Facades\Validator
;
// 医师控制器
// 医师控制器
class
DoctorController
extends
BaseApiController
class
DoctorController
extends
BaseApiController
...
@@ -29,9 +30,12 @@ public function detail()
...
@@ -29,9 +30,12 @@ public function detail()
public
function
upload
(
Request
$request
)
public
function
upload
(
Request
$request
)
{
{
// 验证上传的图片文件
// 验证上传的图片文件
$validat
ed
=
$request
->
validate
(
[
$validat
or
=
Validator
::
make
(
$request
->
all
(),
[
'image'
=>
'required|image|mimes:jpeg,png,jpg
,gif,svg
|max:2048'
,
'image'
=>
'required|image|mimes:jpeg,png,jpg|max:2048'
,
]);
]);
if
(
$validator
->
fails
())
{
return
$this
->
failed
(
'图片必须2Mb以内,且是jpeg,png,jpg三种格式~'
);
}
// 获取上传的图片
// 获取上传的图片
if
(
$request
->
hasFile
(
'image'
))
{
if
(
$request
->
hasFile
(
'image'
))
{
...
...
app/Api/Controllers/PharmacistController.php
View file @
34f179db
...
@@ -155,9 +155,12 @@ public function upload(Request $request)
...
@@ -155,9 +155,12 @@ public function upload(Request $request)
{
{
// 验证上传的图片文件
// 验证上传的图片文件
$validat
ed
=
$request
->
validate
(
[
$validat
or
=
Validator
::
make
(
$request
->
all
(),
[
'image'
=>
'required|image|mimes:jpeg,png,jpg
,gif,svg
|max:2048'
,
'image'
=>
'required|image|mimes:jpeg,png,jpg|max:2048'
,
]);
]);
if
(
$validator
->
fails
())
{
return
$this
->
failed
(
'图片必须2Mb以内,且是jpeg,png,jpg三种格式~'
);
}
// 验证药师编号
// 验证药师编号
$pharmacist_id
=
$request
->
input
(
'pharmacist_id'
);
$pharmacist_id
=
$request
->
input
(
'pharmacist_id'
);
if
(
empty
(
$pharmacist_id
)
||
!
filter_var
(
$pharmacist_id
,
FILTER_VALIDATE_INT
))
{
if
(
empty
(
$pharmacist_id
)
||
!
filter_var
(
$pharmacist_id
,
FILTER_VALIDATE_INT
))
{
...
...
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