2013-03-15 2 views
0

그래서 나는 다음과 같은 코드가 개방되지 :우편 아카이브

$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());

했고 그들은 내가 ZipArchive 지원하지 않는 생각 읽기를 한 후 우는 소리

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

PHP 또는 ZipArchive 클래스가 스트림에서 파일을 열 수 없도록 설정되었을 가능성이 큽니다. 문서를보고 ZipArchive가'open()'호출이 실패한 이유를 알려주는 메소드가 있는지 확인해야합니다. – Cfreak

+0

.zip 파일을 저장하고 로컬 위치를 가리키면 어떻게됩니까? –

+0

int 11이므로 실패합니다. – TheWebs

답변

1

있습니다

업데이트

나는의 resaults가 무엇인지 질문을 받았다 URI를 통해 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 설정이 활성화되어 있는지 확인합니다.

관련 문제