php在线打包下载
来源:互联网 发布:sql往表中添加新数据 编辑:程序博客网 时间:2024/04/29 05:33
<?php
$button="";
if(isset($_POST['button'])){
$button=$_POST['button'];
}
if($button=="下载")
{
$zip = new ZipArchive();
$filename = "./myimages.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("无法创建 <$filename>\n");
}
$files = listdir();
foreach($files as $path)
{
$zip->addFile($path,str_replace("./","",str_replace("\\","/",$path)));
}
echo "压缩完成,共压缩了: " . $zip->numFiles . "个文件\n";
$zip->close();
}
Function listdir($start_dir='./myimages/') {
$files = array();
if (is_dir($start_dir)) {
$fh = opendir($start_dir);
while (($file = readdir($fh)) !== false) {
if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
$filepath = $start_dir . '/' . $file;
if ( is_dir($filepath) )
$files = array_merge($files, listdir($filepath));
else
array_push($files, $filepath);
}
closedir($fh);
} else {
$files = false;
}
return $files;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>下载</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form name="form1" method="post" action="">
<hr size="1">
<P> <input type="submit" name="button" value="下载" /></P>
</form>
</body>
</html>
$button="";
if(isset($_POST['button'])){
$button=$_POST['button'];
}
if($button=="下载")
{
$zip = new ZipArchive();
$filename = "./myimages.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("无法创建 <$filename>\n");
}
$files = listdir();
foreach($files as $path)
{
$zip->addFile($path,str_replace("./","",str_replace("\\","/",$path)));
}
echo "压缩完成,共压缩了: " . $zip->numFiles . "个文件\n";
$zip->close();
}
Function listdir($start_dir='./myimages/') {
$files = array();
if (is_dir($start_dir)) {
$fh = opendir($start_dir);
while (($file = readdir($fh)) !== false) {
if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
$filepath = $start_dir . '/' . $file;
if ( is_dir($filepath) )
$files = array_merge($files, listdir($filepath));
else
array_push($files, $filepath);
}
closedir($fh);
} else {
$files = false;
}
return $files;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>下载</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<form name="form1" method="post" action="">
<hr size="1">
<P> <input type="submit" name="button" value="下载" /></P>
</form>
</body>
</html>
0 0
- php在线打包下载
- php文件打包下载
- php打包下载文件
- 诺学网c++视频教程在线观看+打包下载
- PHP多文件打包下载
- PHP打包下载多文件
- php zip打包下载文件
- php 打包下载zlib函数
- PHP打包下载zip文件
- 多文件打包下载PHP
- PHP 文件下载程序 文件打包下载
- 利用PHP实现在线下载大文件
- paypal在线支付演示下载PHP版
- PHP100的php教程批量打包下载
- 使用php实现下载打包文件
- php视频教程打包下载 - 网络上最好的php视频教程
- 【在线解压缩PHP脚本】程序使用及免费下载
- php中怎样实现图片的打包下载
- 位图信息头BITMAPINFOHEADER
- eclipse 上使用maven建web项目
- Windows网络编程相关概念
- Android的sp与dp
- 父元素和子元素都有点击事件
- php在线打包下载
- [iPhone高级] 基于XMPP的IOS聊天客户端程序(IOS端三)
- java Jvm工作原理学习笔记
- java 枚举——java(android)中枚举的运用和使用场景
- Makefile中常用的函数
- Android实用代码七段(五)
- Java 日期时间 Date类型,long类型,String类型表现形式的转换
- 扩展欧几里德算法
- 解决自定义标题栏You cannot combine custom titles with other title features问题