php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78520 php download file name ≈你 好;123.zip
Submitted: 2019-09-10 03:14 UTC Modified: 2019-09-10 05:40 UTC
From: 77738609 at qq dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.4.0RC1 OS:
Private report: No CVE-ID: None
 [2019-09-10 03:14 UTC] 77738609 at qq dot com
Description:
------------
php download file name '≈你 好;123.zip'; file name is &ap

c# can download 

Test script:
---------------
php download file name '≈你 好;123.zip';
$filename = iconv('utf-8',"gbk//IGNORE",$filename);

$filepath = 'D:/www/'.$filename;


$file=fopen($filepath,"r");

header("Content-type:text/html;charset=utf-8");

header("Content-Type: application/octet-stream");

header("Accept-Ranges: bytes");

header("Accept-Length: ".filesize($filepath));

header("Content-Disposition: attachment; filename= $filename ; filename*=utf-8''$filename ");

echo fread($file,filesize($filepath));

fclose($file);

Expected result:
----------------
php download file name '≈你 好;123.zip';

Actual result:
--------------
php download file name '≈你 好;123.zip';

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-10 03:26 UTC] 77738609 at qq dot com
Actual result:&ap 

Expected result: '≈你 好;123.zip';
 [2019-09-10 05:40 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: *URL Functions +Package: *General Issues
 [2019-09-10 05:40 UTC] requinix@php.net
If $filename has semicolons then it needs to be quoted in the Content-Disposition, and it's using the wrong encoding.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 01:01:28 2024 UTC