ZipArchive encoding with Japanese file name

This is what I did

$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 does not display correctly, but it looks like this: T ¢ + s¡És + Åpâ "péñpâ | pé + pâ.jpeg

Please help me!!!

+6
source share
1 answer

Try using the code below if it doesn’t work, try renaming the file name inside zip to English and see if it works then. If so, then the problem is not in the ZipArchive or in the zip archive at all.

 $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(); 
0
source

All Articles