幸好 pclzip 有提供變更檔案名稱的方法 (News,連結可能會變動)。在 User Guide 裡沒有寫出來,所以花了點時間才找到。大約的寫法是像這樣:
$big5DirName = iconv('UTF-8', 'Big5', '中文目錄名/');
foreach( $queue as $utf8filename ) {
if( file_exists($file_hosting_dir.$utf8filename) ) {
$zipFiles[] = array(
PCLZIP_ATT_FILE_NAME => $file_hosting_dir.$utf8filename,
PCLZIP_ATT_FILE_NEW_FULL_NAME => $big5DirName.iconv('UTF-8', 'Big5', $utf8filename) );
}
}
if( !tep_not_null($zipFiles) ) {
echo '無可下載檔案。';
exit;
}
$archive = new PclZip($zip_tmp_file_path_name);
$v_list = '';
$v_list = $archive->create($downloadFiles);
if ($v_list == 0) {
die("ERROR : '".$archive->errorInfo(true)."'");
}



0 回應:
張貼意見