Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
fe36bc9e
Commit
fe36bc9e
authored
Aug 19, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`options` parameter extracted at `yii\web\Response::xSendFile()`
parent
e3cea213
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
Response.php
framework/web/Response.php
+14
-4
No files found.
framework/web/Response.php
View file @
fe36bc9e
...
...
@@ -632,11 +632,12 @@ class Response extends \yii\base\Response
* @param string $filePath file name with full path
* @param string $attachmentName file name shown to the user. If null, it will be determined from `$filePath`.
* @param string $mimeType the MIME type of the file. If null, it will be determined based on `$filePath`.
* @param boolean $forceDownload whether the file will be downloaded or shown inline.
* @param string $xHeader the name of the x-sendfile header.
* @param array $options additional options. Valid options are:
* - forceDownload: boolean, whether the file will be downloaded or shown inline. Defaults to true.
* - xHeader: string, the name of the x-sendfile header. Defaults to "X-Sendfile".
* @return static the response object itself
*/
public
function
xSendFile
(
$filePath
,
$attachmentName
=
null
,
$mimeType
=
null
,
$
forceDownload
=
true
,
$xHeader
=
'X-Sendfile'
)
public
function
xSendFile
(
$filePath
,
$attachmentName
=
null
,
$mimeType
=
null
,
$
options
=
[]
)
{
if
(
$mimeType
===
null
&&
(
$mimeType
=
FileHelper
::
getMimeTypeByExtension
(
$filePath
))
===
null
)
{
$mimeType
=
'application/octet-stream'
;
...
...
@@ -644,7 +645,16 @@ class Response extends \yii\base\Response
if
(
$attachmentName
===
null
)
{
$attachmentName
=
basename
(
$filePath
);
}
$disposition
=
$forceDownload
?
'attachment'
:
'inline'
;
if
(
isset
(
$options
[
'xHeader'
]))
{
$xHeader
=
$options
[
'xHeader'
];
}
else
{
$xHeader
=
'X-Sendfile'
;
}
if
(
!
isset
(
$options
[
'forceDownload'
])
||
$options
[
'forceDownload'
])
{
$disposition
=
'attachment'
;
}
else
{
$disposition
=
'inline'
;
}
$this
->
getHeaders
()
->
setDefault
(
$xHeader
,
$filePath
)
...
...
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