In memory download and extract zip archive

后端 未结 4 1933
失恋的感觉
失恋的感觉 2020-12-18 00:13

I would like to download a zip archive and unzip it in memory using PHP.

This is what I have today (and it\'s just too much file-handling for me :) ):



        
4条回答
  •  清歌不尽
    2020-12-18 01:04

    You can get a stream to a file inside the zip and extract it into a variable:

    $fp = $zip->getStream('test.txt');
    if(!$fp) exit("failed\n");
    
    while (!feof($fp)) {
        $contents .= fread($fp, 1024);
    }
    
    fclose($fp);
    

提交回复
热议问题