addFromString():对于ziparchive无效或未初始化

时间:2019-01-19 22:49:52

标签: php ziparchive

我尝试创建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));
}

0 个答案:

没有答案