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
ed5f9795
Commit
ed5f9795
authored
Nov 19, 2020
by
jiangkebao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件流下载
parent
1d22a338
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
functions.php
src/functions.php
+22
-0
No files found.
src/functions.php
View file @
ed5f9795
...
@@ -850,3 +850,25 @@ if (!function_exists('download_file')) {
...
@@ -850,3 +850,25 @@ if (!function_exists('download_file')) {
return
$path
.
'/'
.
$filename
;;
return
$path
.
'/'
.
$filename
;;
}
}
}
}
if
(
!
function_exists
(
'download_file_stream'
))
{
/**文件流保存到本地
* @param $fileStream 文件流
* @param null $path 保存路径
* @return string
*/
function
download_file_stream
(
$fileStream
,
$path
=
null
)
{
$root
=
config
(
'server.settings.document_root'
,
BASE_PATH
.
'/public'
);
$path
=
$path
?
$path
:
'/download/files'
;
$savePath
=
$root
.
$path
;
if
(
!
is_dir
(
$savePath
))
{
// 判断路径是否存在,不存在,则创建
mkdir
(
$savePath
,
0777
,
true
);
}
$fileName
=
'/'
.
date
(
'YmdHis'
)
.
'track'
.
'.pdf'
;
file_put_contents
(
$savePath
.
$fileName
,
base64_decode
(
$fileStream
),
1
);
return
$path
.
$fileName
;
}
}
\ No newline at end of file
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