dti3914 2017-10-16 19:57
浏览 6

如何识别zip错误

When I tried to extract a zip file downloaded, it does'nt work. How to identifed the error ?

the response is failed;

Thank you.

File location //home/www/boutique/includes/ClicShopping/Work/IceCat/daily.index.xml.gz

     public function ExtractZip() {

  if (is_file($this->selectFile())) {
    $zip = new \ZipArchive;

    if ($zip->open($this->selectFile()) === true) {

      $zip->extractTo($this->IceCatDirectory);
      $zip->close();

      echo 'file downloaded an unzipped';
    }
  } else {
    echo 'error no file found in ' . $this->selectFile();
  }
}
  • 写回答

1条回答 默认 最新

  • dongqiao0953 2017-10-16 21:02
    关注

    Follow to comment, there the correct function

        public function ExtractGzip() {
    
    // Raising this value may increase performance
          $buffer_size = 4096; // read 4kb at a time
          $out_file_name = str_replace('.gz', '', $this->selectFile());
    
    // Open our files (in binary mode)
          $file = gzopen($this->selectFile(), 'rb');
          $out_file = fopen($out_file_name, 'wb');
    
    // Keep repeating until the end of the input file
          while(!gzeof($file)) {
            // Read buffer-size bytes
            // Both fwrite and gzread and binary-safe
            fwrite($out_file, gzread($file, $buffer_size));
          }
    
    // Files are done, close files
          fclose($out_file);
          gzclose($file);
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度