手机
当前位置:查字典教程网 >编程开发 >php教程 >服务器端解压缩zip的脚本
服务器端解压缩zip的脚本
摘要:复制代码代码如下:文件解压缩管理

复制代码 代码如下:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>

<title>文件解压缩管理</title>

</head>

<body>

<?php

//InPHPversionsearlierthan4.1.0,$HTTP_POST_FILESshouldbeusedinstead

//of$_FILES.

if(isset($_POST["Submit"])){

echo"FileName:".$_POST['unpackfile']."<br/>n";

echo"UnpackPath:".$_POST['unpackpath']."<br/>n";

$zip=zip_open($_POST['unpackfile']);

if($zip){

while($zip_entry=zip_read($zip)){

echo"Name:".zip_entry_name($zip_entry)."<br/>n";

echo"ActualFilesize:".zip_entry_filesize($zip_entry)."<br/>n";

echo"CompressedSize:".zip_entry_compressedsize($zip_entry)."<br/>n";

echo"CompressionMethod:".zip_entry_compressionmethod($zip_entry)."<br/>n";

if(zip_entry_open($zip,$zip_entry,"r")){

$buf=zip_entry_read($zip_entry,zip_entry_filesize($zip_entry));//Filecontent

echo"step1successful!<br/>n";

if(zip_entry_filesize($zip_entry)!=0){

$fp=fopen($_POST['unpackpath']."/".zip_entry_name($zip_entry),'wb');

fwrite($fp,$buf);

fclose($fp);

zip_entry_close($zip_entry);

echo"unpacksuccessful!<br/>n";

}else{

mkdir($_POST['unpackpath']."/".zip_entry_name($zip_entry),0777);

echo"mkdirsuccessful!<br/>n";

}

}

echo"<br><br>nn";

}

zip_close($zip);

}

?>

</body>

</html>

<?php

exit();

}

?>

<formid="form1"name="form1"enctype="multipart/form-data"method="post"action="<?=$_SERVER['PHP_SELF']?>">

待解压文件<inputtype="text"name="unpackfile"/>

解压缩路径<inputtype="text"name="unpackpath"/>

<inputtype="submit"name="Submit"value="解压"/>

</form>

</body>

</html>

【服务器端解压缩zip的脚本】相关文章:

php生成图片缩略图的方法

php筛选不存在的图片资源

PHP加密解密字符串汇总

如何正确理解PHP的错误信息

建立文件交换功能的脚本(一)

php采集中国代理服务器网的方法

PHP rsa加密解密使用方法

WINDOWS服务器安装多套PHP的另类解决方案

PHP准确取得服务器IP地址的方法

CodeIgniter针对lighttpd服务器URL重写的方法

精品推荐
分类导航