【发布时间】:2015-07-01 08:47:00
【问题描述】:
我正在 UNIX 系统上使用 PHP 5.3.10 和 Zip 版本 1.12.5 和 Libzip 版本 0.11.2 创建 ZIP 存档:
<?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 在 Windows 7 上打开生成的 ZIP 文件 test.zip 时,我看到存档中的文件类似于“Liste client +а exporter.txt”而不是“Liste client à 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
【问题讨论】:
-
以解密格式打开的压缩文件?
-
不明白你的意思。下载后会自动打开。双击zip文件时效果相同。
-
究竟是什么问题
-
问题是当使用内部 Windows arhciver 打开存档时,它显示的文件名没有重音符号。
标签: php windows-7 ziparchive non-ascii-characters