php 文件在线解压代码_PHP教程

WBOY
發布: 2016-07-20 11:06:44
原創
999 人瀏覽過

public function ExtractFile($header,$to,$zip) {
  $header = $this->readfileheader($zip);

  if (substr($to,-1)!="/") $to.="/";
  if ($to=='./') $to = '';
  $pth = explode("/",$to.$header['filename']);
  $mydir = '';
  for($i=0;$i   if (!$pth[$i]) continue;
   $mydir .= $pth[$i]."/";
   if ((!is_dir($mydir) && @mkdir($mydir,0777)) || (($mydir==$to.$header['filename'] || ($mydir==$to && $this->total_folders==0)) && is_dir($mydir)) ) {
    @chmod($mydir,0777);
    $this->total_folders ++;
    echo 'Extract : ',$mydir,'
';
   }
  }

  if (strrchr($header['filename'],'/')=='/') return;
  if (!($header['external']==0x41FF0010)&&!($header['external']==16)) {
   if ($header['compression']==0) {
    $fp = @fopen($to.$header['filename'], 'wb');
    if (!$fp) return(-1);
    $size = $header['compressed_size'];
    while ($size != 0) {
     $read_size = ($size      $buffer = fread($zip, $read_size);
     $binary_data = pack('a'.$read_size, $buffer);
     @fwrite($fp, $binary_data, $read_size);
     $size -= $read_size;
    }
    fclose($fp);
    touch($to.$header['filename'], $header['mtime']);
   } else {
    $fp = @fopen($to.$header['filename'].'.gz','wb');
    if (!$fp) return(-1);
    $binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($header['compression']),
    Chr(0x00), time(), Chr(0x00), Chr(3));

    fwrite($fp, $binary_data, 10);
    $size = $header['compressed_size'];

    while ($size != 0) {
     $read_size = ($size      $buffer = fread($zip, $read_size);
     $binary_data = pack('a'.$read_size, $buffer);
     @fwrite($fp, $binary_data, $read_size);
     $size -= $read_size;
    }

    $binary_data = pack('VV', $header['crc'], $header['size']);
    fwrite($fp, $binary_data,8); fclose($fp);

    $gzp = @gzopen($to.$header['filename'].'.gz','rb') or die("Cette archive est compress

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445020.htmlTechArticlepublic function ExtractFile($header,$to,$zip) { $header = $this-readfileheader($zip); if (substr($to,-1)!=/) $to.=/; if ($to=='./') $to = ''; $pth = explode(/,$to.$header['filename...
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板