Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用ZipArchive失败_Php_Html_Mysql_Css - Fatal编程技术网

Php 使用ZipArchive失败

Php 使用ZipArchive失败,php,html,mysql,css,Php,Html,Mysql,Css,我将使用PHP类创建一个Zip存档。但它仍然不起作用。 它不会失败,响应为1。他没有创建Zip文件 $zip = new ZipArchive; $res = $zip->open('qr_img/'.'ab387bas.zip'.'', ZipArchive::CREATE); if ($res === TRUE) { $zip->addFile($file, 'screen.png'); $zip->close(); } 每个人都知道答案吗?$file\u

我将使用PHP类创建一个Zip存档。但它仍然不起作用。 它不会失败,响应为1。他没有创建Zip文件

$zip = new ZipArchive;
$res = $zip->open('qr_img/'.'ab387bas.zip'.'', ZipArchive::CREATE);
if ($res === TRUE) {
    $zip->addFile($file, 'screen.png');
    $zip->close();
}

每个人都知道答案吗?

$file\u names
是要添加到zip中的文件数组

 function zipFile($file_names,$archive_file_name)
{
    $zip = new ZipArchive();
    //create the file and throw the error if unsuccessful
    if ($zip->open($archive_file_name, ZIPARCHIVE::OVERWRITE )!==TRUE) {

    }

    //add each files of $file_name array to archive
    foreach($file_names as $files)
    {
    //  $zip->addFile($files,$files);
        $zip->addFromString(basename($files),  file_get_contents($files));
    }
    $zip->close();


}

请看我的回答:回答“1”实际上是一个错误代码,请在internet上查找。它在页面底部:如果$res==1,则表示
不支持多磁盘zip存档
谢谢,但我能做些什么?如果zip是您自己生成的,请生成它,使其不是多磁盘。如果zip存档应该由用户上传,则向他们显示一条消息,说明同样的情况。