2

I have used ZipArchive for creating zip. but i have problem with filename assign in Arabic language that is not supported.

I want to get filename like 21_بينل.pdf but i getting 21_.pdf.

I have refer following question.

PHP ZipArchive non-English filenames return funky filenames within archive

but still not working.

My sample code:

<?php
     $zip = new ZipArchive;
     $res = $zip->open('test.zip', ZipArchive::CREATE);
     $fileName = $v->certificateLetter->fileName.'/'.$v->dslStu->stu_unique_id.'_'.'بينل';
     $zip->addFromString($fileName.'.pdf', $letterString);
     $zip->close();
?>

Thanks in Advance.

Maythux
  • 103
  • 7
GAMITG
  • 3,810
  • 7
  • 32
  • 51

1 Answers1

0

Try this:

$zip = new ZipArchive;
$res = $zip->open('test.zip', ZipArchive::CREATE);
$fileName = $v->certificateLetter->fileName.'/'.$v->dslStu->stu_unique_id.'_'.'بينل';
iconv('CP1256', 'utf-8', $fileName).PHP_EOL;
$zip->addFromString($fileName.'.pdf', $letterString);
$zip->close();
devpro
  • 16,184
  • 3
  • 27
  • 38
  • @GAMITG: you can check here regarding your language: http://php.net/manual/en/function.iconv.php – devpro Dec 30 '15 at 09:52
  • try this for arabic language: iconv('cp1256', 'utf-8', $fileName); CP1256 for MS-ARAB WINDOWS-1256... updated in answer @GAMITG – devpro Dec 30 '15 at 09:55