2015-04-23 63 views
0

我对UNIX系统采用PHP 5.3.10与邮编版本1.12.5和Libzip版本0.11.2创建ZIP档案口音字符:PHP ZipArchive文件名中使用

<?php 
$zip = new ZipArchive(); 
$test_zip = "./test.zip"; 
if ($zip->open($test_zip, ZIPARCHIVE::CREATE)===TRUE) 
{ 
    $zip->addFromString("Liste client à exporter.txt","Content line 1\nContent line 2\n"); 
    $zip->close(); 

    if(file_exists($test_zip)) 
    { 
     header ("Content-Type: application/octet-stream"); 
     header ("Accept-Ranges: bytes"); 
     header ("Content-Length: ".filesize($test_zip)); 
     header ("Content-Disposition: attachment; filename=\"test.zip\""); 
     header ("Cache-Control: max-age=60"); 
     readfile($test_zip); 
     unlink ($test_zip); 
    } 
} 
?> 

,当我打开生成的ZIP文件test.zip上Windows 7使用内部ZIP,我看到文件中的文件,如“Liste客户端+ exporter.txt”而不是“Liste客户端àexporter.txt”。 但是,如果用7z打开它,文件名是正确的,并带有口音。 PHP文件具有UTF-8编码。

解决 问题已在Windows 7(补丁KB2704299)

File names are corrupted after you decompress a .zip file in Windows 7 or in Windows Server 2008 R2

+0

zip文件以解密的形式打开? – RaMeSh

+0

不明白你的意思。下载后自动打开。双击zip文件时效果相同。 –

+0

什么是确切的问题 – RaMeSh

回答

0

有同样的问题(我是法国人所以用口音的问题,我知道的)。

为避免此问题,我使用外部zip命令。

对于Linux:

exec("cd \"".$the_directory_you want_to_zip."\" && zip -0 -r \"".$path_zip."\" ."); 
+0

它没有帮助。同样的效果:内部窗口拉开相同的+ a。使用7z的名字是正确的。 –