当前位置: 首页 > 图文教程 > 网络编程 > PHP > 服务器端解压缩zip的脚本

PHP
PHP新手总结的PHP基础知识
php实现gb2312和unicode间编码转换
用php语言实现数据库连接详细代码介绍
详细解析 PHP 向 MySQL 发送数据过程
利用PHP V5开发多任务应用程序
详细讲解PHP中缓存技术的应用
php escapeshellcmd多字节编码漏洞
《PHP设计模式介绍》导言
《PHP设计模式介绍》第一章 编程惯用法
《PHP设计模式介绍》第二章 值对象模式
《PHP设计模式介绍》第三章 工厂模式
《PHP设计模式介绍》第四章 单件模式
《PHP设计模式介绍》第五章 注册模式
《PHP设计模式介绍》第六章 伪对象模式
《PHP设计模式介绍》第七章 策略模式
《PHP设计模式介绍》第八章 迭代器模式
《PHP设计模式介绍》第九章 观测模式
《PHP设计模式介绍》第十章 规范模式
《PHP设计模式介绍》第十一章 代理模式
《PHP设计模式介绍》第十二章 装饰器模式

PHP 中的 服务器端解压缩zip的脚本


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 133 ::
收藏到网摘: n/a

复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文件解压缩管理</title>
</head>
<body>
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// 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 "Actual Filesize: " . zip_entry_filesize($zip_entry) . "<br />\n";
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "<br />\n";
echo "Compression Method: " . 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)); // File content
echo "step 1 successful!<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 "unpack successful!<br />\n";
} else {
mkdir($_POST['unpackpath']."/".zip_entry_name($zip_entry), 0777);
echo "mkdir successful!<br />\n";
}
}
echo "<br><br>\n\n";
}
zip_close($zip);
}
?>
</body>
</html>
<?php
exit();
}
?>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="<?=$_SERVER['PHP_SELF']?>">
待解压文件<input type="text" name="unpackfile" />
解压缩路径<input type="text" name="unpackpath" />
<input type="submit" name="Submit" value="解压" />
</form>
</body>
</html>