Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
without authentication
meibuyu-micro
Commits
7432bfdd
Commit
7432bfdd
authored
Mar 31, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
排除上传文件后缀名大小写
parent
640ca6ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
2 deletions
+1
-2
UploadManager.php
src/Manager/UploadManager.php
+1
-2
No files found.
src/Manager/UploadManager.php
View file @
7432bfdd
...
...
@@ -71,14 +71,13 @@ class UploadManager
if
(
$file
->
isValid
())
{
$extension
=
$file
->
getExtension
();
// 通过扩展名判断类型
if
(
!
in_array
(
$extension
,
$options
[
'mime'
]))
{
if
(
!
in_array
(
strtolower
(
$extension
)
,
$options
[
'mime'
]))
{
throw
new
HttpResponseException
(
'文件类型不支持,目前只支持'
.
implode
(
','
,
$options
[
'mime'
]));
}
// 判断文件大小
if
(
$file
->
getSize
()
>
$options
[
'maxSize'
])
{
throw
new
HttpResponseException
(
'文件超出系统规定的大小,最大不能超过'
.
$options
[
'maxSize'
]);
}
// 文件重命名,由当前日期时间 + 唯一ID + 扩展名
$fileName
=
date
(
'YmdHis'
)
.
uniqid
()
.
'.'
.
$extension
;
$savePath
=
self
::
parsePath
(
$options
)
.
$fileName
;
...
...
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