所以我有以下代码:
$z = new ZipArchive();
$zopen = $z->open('https://github.com/AdamKyle/Aisis-Framework/archive/Aisis1.1.7.zip', 4);
if ($zopen === true) {
for ($i = 0; $i < $zip->numFiles; $i++) {
$filename = $zip->getNameIndex($i);
var_dump($filename);
}
} else {
echo "fail";
}
exit;
它一直导致失败。我提供的URL在浏览器中适用于我,但不在上面的代码中。发生了什么事?
更新
有人问我被解雇了什么:
var_dump(stream_get_wrappers());
他们是咆哮
array (size=12)
0 => string 'https' (length=5)
1 => string 'ftps' (length=4)
2 => string 'compress.zlib' (length=13)
3 => string 'compress.bzip2' (length=14)
4 => string 'php' (length=3)
5 => string 'file' (length=4)
6 => string 'glob' (length=4)
7 => string 'data' (length=4)
8 => string 'http' (length=4)
9 => string 'ftp' (length=3)
10 => string 'phar' (length=4)
11 => string 'zip' (length=3)
答案 0 :(得分:1)
阅读完后,我相信ZipArchive
不支持通过URI打开zip文件。
要使用zip,首先需要将其复制到本地磁盘......
$content = file_get_contents('https://github.com/AdamKyle/Aisis-Framework/archive/Aisis1.1.7.zip');
file_put_contents('/tmp/name.zip', $content);
$zip = new ZipArchive();
$zip->open('/tmp/name.zip');
确保已启用allow_url_fopen
ini设置。