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
e3cea213
Commit
e3cea213
authored
Aug 19, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `forceDownload` parameter to `yii\web\Response::xSendFile()`
parent
76b03a3f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
2 deletions
+8
-2
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
UPGRADE.md
framework/UPGRADE.md
+3
-0
Response.php
framework/web/Response.php
+4
-2
No files found.
framework/CHANGELOG.md
View file @
e3cea213
...
...
@@ -172,6 +172,7 @@ Yii Framework 2 Change Log
-
Enh #4317: Added
`absoluteAuthTimeout`
to yii
\w
eb
\U
ser (ivokund, nkovacs)
-
Enh #4360: Added client validation support for file validator (Skysplit)
-
Enh #4372:
`yii\filters\HttpCache`
failed to comply to RFC 7232 (DaSourcerer)
-
Enh #4424: Added
`forceDownload`
parameter to
`yii\web\Response::xSendFile()`
(klimov-paul)
-
Enh #4436: Added callback functions to AJAX-based form validation (thiagotalma)
-
Enh #4485: Added support for deferred validation in
`ActiveForm`
(Alex-Code)
-
Enh #4520: Added sasl support to
`yii\caching\MemCache`
(xjflyttp)
...
...
framework/UPGRADE.md
View file @
e3cea213
...
...
@@ -196,3 +196,6 @@ new ones save the following code as `convert.php` that should be placed in the s
*
The format of the Faker fixture template is changed. For an example, please refer to the file
`apps/advanced/common/tests/templates/fixtures/user.php`
.
*
Signature of the
`yii\web\Response::xSendFile()`
method has changed. If you're using or overriding this method you
must change your code to fit it.
framework/web/Response.php
View file @
e3cea213
...
...
@@ -632,10 +632,11 @@ 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.
* @return static the response object itself
*/
public
function
xSendFile
(
$filePath
,
$attachmentName
=
null
,
$mimeType
=
null
,
$xHeader
=
'X-Sendfile'
)
public
function
xSendFile
(
$filePath
,
$attachmentName
=
null
,
$mimeType
=
null
,
$
forceDownload
=
true
,
$
xHeader
=
'X-Sendfile'
)
{
if
(
$mimeType
===
null
&&
(
$mimeType
=
FileHelper
::
getMimeTypeByExtension
(
$filePath
))
===
null
)
{
$mimeType
=
'application/octet-stream'
;
...
...
@@ -643,11 +644,12 @@ class Response extends \yii\base\Response
if
(
$attachmentName
===
null
)
{
$attachmentName
=
basename
(
$filePath
);
}
$disposition
=
$forceDownload
?
'attachment'
:
'inline'
;
$this
->
getHeaders
()
->
setDefault
(
$xHeader
,
$filePath
)
->
setDefault
(
'Content-Type'
,
$mimeType
)
->
setDefault
(
'Content-Disposition'
,
"
attachment; filename=
\"
$attachmentName
\"
"
);
->
setDefault
(
'Content-Disposition'
,
"
{
$disposition
}
; filename=
\"
{
$attachmentName
}
\"
"
);
return
$this
;
}
...
...
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