Browse Source

string helper fixed, mime-type reverted

tags/2.0.0-beta
Ragazzo 12 years ago
parent
commit
959cff3e9b
  1. 9
      yii/web/Response.php

9
yii/web/Response.php

@ -10,6 +10,7 @@ namespace yii\web;
use Yii;
use yii\helpers\FileHelper;
use yii\helpers\Html;
use yii\helpers\StringHelper;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
@ -36,12 +37,12 @@ class Response extends \yii\base\Response
public function sendFile($fileName, $content, $mimeType = null, $terminate = true)
{
if ($mimeType === null) {
if (($mimeType = CFileHelper::getMimeTypeByExtension($fileName)) === null) {
$mimeType='text/plain';
if (($mimeType = FileHelper::getMimeTypeByExtension($fileName)) === null) {
$mimeType='application/octet-stream';
}
}
$fileSize = (function_exists('mb_strlen') ? mb_strlen($content,'8bit') : strlen($content));
$fileSize = StringHelper::strlen($content);
$contentStart = 0;
$contentEnd = $fileSize - 1;
@ -102,7 +103,7 @@ class Response extends \yii\base\Response
header('Content-Length: '.$length);
header("Content-Disposition: attachment; filename=\"$fileName\"");
header('Content-Transfer-Encoding: binary');
$content = function_exists('mb_substr') ? mb_substr($content,$contentStart,$length) : substr($content,$contentStart,$length);
$content = StringHelper::strlen($content);
if ($terminate) {
// clean up the application first because the file downloading could take long time

Loading…
Cancel
Save