Problem with greek filename for ZipArchive::addFile

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
A.Evagelopoulos
Forum Newbie
Posts: 1
Joined: Fri Dec 03, 2010 7:18 am

Problem with greek filename for ZipArchive::addFile

Post by A.Evagelopoulos »

Hi,
i try to create a zip file with several files.
when i add a file with non Latin characters in the filename(in my example greek letters), the result is that the file will successfully added to zip archive but with wrong filename. i tried to use several functions and charset combinations (like iconv, md_convert_encoding) but when i try to open the zip file with winZip or windows explorer i get the same error.
original filename Εικόνα024.jpg
filename in zip +ώΆ_Ίά024.jpg

my code :

Code: Select all

$zip = new ZipArchive;
$res = $zip->open("test.zip", ZIPARCHIVE::OVERWRITE );
if ($res === TRUE) {
    $zip->addFile("test.txt");
    $zip->addFile("Εικόνα024.jpg");
    //here i tried several things but nothing seems to work
    //$zip->addFile("Εικόνα024.jpg",iconv("ISO-8859-7","UTF-8","Εικόνα024.jpg"));
    //$zip->addFile("Εικόνα024.jpg",iconv("ISO-8859-7","ISO-8859-1","Εικόνα024.jpg"));
    //
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
Any idea how can i solve this
Post Reply