我尝试创建zip存档时遇到问题。 我有这个错误:
警告:ZipArchive :: addFromString():无效或未初始化的Zip对象
代码
$Zip = new \ZipArchive();
$intent_file = 'dialogflow_api' . '-' . date('YmdHis') . '.zip';
$result = $Zip->open($transfer_directory . $intent_file, $Zip->CREATE);
if ($result) {
foreach ($apps as $data) {
$file = $data['products_name'];
$json_structure .= '
"supportedLanguages": [
"' . $language_code . '"
]
';
$json_structure .='}'
$Zip->addFromString('intents/' . $file . '_' . $language_code . '.json', $json_structure);
}
$Zip->close();
} else {
error_log('OM\Zip::open() ' . $transfer_directory . $intent_file . ' file error: ' . $Zip->message($result));
}