Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
8770d0ae
Commit
8770d0ae
authored
Jun 26, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tweaked File::is method.
parent
6f5aca8d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
system/file.php
+19
-19
No files found.
system/file.php
View file @
8770d0ae
...
...
@@ -137,25 +137,6 @@ class File {
}
/**
* Determine if a file is a given type.
*
* The Fileinfo PHP extension will be used to determine the MIME
* type of the file. Any extension in the File::$mimes array may
* be passed as a type.
*/
public
static
function
is
(
$extension
,
$path
)
{
if
(
!
array_key_exists
(
$extension
,
static
::
$mimes
))
{
throw
new
\Exception
(
"File extension [
$extension
] is unknown. Cannot determine file type."
);
}
$mime
=
finfo_file
(
finfo_open
(
FILEINFO_MIME_TYPE
),
$path
);
return
(
is_array
(
static
::
$mimes
[
$extension
]))
?
in_array
(
$mime
,
static
::
$mimes
[
$extension
])
:
$mime
===
static
::
$mimes
[
$extension
];
}
/**
* Extract the extension from a file path.
*
* @param string $path
...
...
@@ -184,6 +165,25 @@ class File {
}
/**
* Determine if a file is a given type.
*
* The Fileinfo PHP extension will be used to determine the MIME
* type of the file. Any extension in the File::$mimes array may
* be passed as a type.
*/
public
static
function
is
(
$extension
,
$path
)
{
if
(
!
array_key_exists
(
$extension
,
static
::
$mimes
))
{
throw
new
\Exception
(
"File extension [
$extension
] is unknown. Cannot determine file type."
);
}
$mime
=
finfo_file
(
finfo_open
(
FILEINFO_MIME_TYPE
),
$path
);
return
(
is_array
(
static
::
$mimes
[
$extension
]))
?
in_array
(
$mime
,
static
::
$mimes
[
$extension
])
:
$mime
===
static
::
$mimes
[
$extension
];
}
/**
* Create a response that will force a file to be downloaded.
*
* @param string $path
...
...
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