Browse Source

Fixed:文件名称中空格中文字符问题

Zhu Jinhui 6 years ago
parent
commit
3374b56e67
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/Library/Download.php

+ 3 - 3
src/Library/Download.php

@@ -23,7 +23,7 @@ class Download
 		header('Cache-Control: pre-check=0, post-check=0, max-age=0');
 		header("Content-type: application/octet-stream");
 		header("Accept-Length: ".  sizeof($string));
-		$fileName = iconv("UTF-8", "GB2312//TRANSLIT", $fileName);
+		$fileName = toGBK(urlencode($fileName));
 		header("Content-Disposition: attachment; filename=". $fileName);
 		echo $string;
 	}
@@ -72,7 +72,7 @@ class Download
 		}
 		header("Cache-control: public");
 		header("Pragma: public");
-		$fileName = iconv("UTF-8", "GB2312//TRANSLIT", $fileName);
+		$fileName = toGBK(urlencode($fileName));
 		header('Content-Dispositon:attachment; filename=' . $fileName);
 		$fp = fopen($filePath, 'rb+');
 		fseek($fp, $range);
@@ -126,7 +126,7 @@ class Download
 		header('Content-Transfer-Encoding: binary');
 		header("Accept-Ranges: bytes");
 		header("Accept-Length: ".  filesize($filePath));
-		$fileName = toGBK($fileName);
+		$fileName = toGBK(urlencode($fileName));
 		if($view == 'download')
 		{
 			header("Content-Disposition: attachment; filename=". $fileName);