【问题标题】:How to extract a zip file and save files to folder and file name to database using PHP?如何使用 PHP 提取 zip 文件并将文件保存到文件夹和文件名到数据库?
【发布时间】:2010-09-02 08:59:49
【问题描述】:

如何使用 PHP 提取 zip 文件并将文件保存到文件夹和文件名到数据库?

【问题讨论】:

  • 通过谷歌搜索如何做到这一点的教程。
  • @captaintokyo - 如果你必须用谷歌搜索所有答案,那么这个网站的意义何在?
  • 提出问题,而不是请求可以通过谷歌搜索甚至搜索同一站点轻松找到的教程。

标签: php mysql zip winrar


【解决方案1】:

【讨论】:

    【解决方案2】:

    这里是:

    $zip = zip_open("xyz.zip");
    if ($zip) {
      while ($zip_entry = zip_read($zip)) {
        $fp = fopen("zip/".zip_entry_name($zip_entry), "w");
    
        // write the file name zip_entry_name($zip_entry) to DB here
    
        if (zip_entry_open($zip, $zip_entry, "r")) {
          $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
          fwrite($fp,"$buf");
          zip_entry_close($zip_entry);
          fclose($fp);
        }
      }
      zip_close($zip);
    }
    

    【讨论】:

    • 不知道,有些人没有正确阅读答案就投了反对票。
    • 请注意,使用zip_entry_read()zip_entry_filesize() 作为缓冲区大小对于较大的文件会失败...
    猜你喜欢
    • 2023-03-29
    • 1970-01-01
    • 2014-07-18
    • 2018-09-30
    • 1970-01-01
    • 2019-05-04
    • 2014-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多