简体   繁体   中英

ZipArchive encoding with japanese file name

This is what I have done

$zip = new \ZipArchive;
    $zip->open('file.zip', \ZipArchive::CREATE | \ZIPARCHIVE::OVERWRITE);
    foreach ($files as $file) { 
        $zip->addFile( "images/ルフィエール.jpeg");   
    }

but inside the zip file it's not show properly, but it show like this : T¢+s¡És+Åpâ»péñpâ¦pé+pâ.jpeg

Please help me!!!

Try using the code below, if it doesn't work try renaming the filename inside the zip to English, and see if it works then. If it does, then the issue is not from ZipArchive or zipping in general.

$zip = new \ZipArchive;
$zip->open('file.zip', \ZipArchive::CREATE | \ZIPARCHIVE::OVERWRITE);
foreach ($files as $file) { 
// Hopefully the filename below is dynamic and you're not actually adding the same file over and over
    $file = "images/ルフィエール.jpeg";
    $content = file_get_contents($file); 
    //if it is possible for you, I would change the filename to english below as well if this doesn't work
    $file_added = $zip->addFromString( pathinfo($file,PATHINFO_BASENAME) , $content);
}
$zip->close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM