手机
当前位置:查字典教程网 >编程开发 >php教程 >php 在线打包_支持子目录
php 在线打包_支持子目录
摘要:程序使用了php的zip扩展,如果服务器支持,那就可以用了^_^,生成的zip压缩包可以用winrar等来解压的,当然也可以用php来解压。...

程序使用了php的zip扩展,如果服务器支持,那就可以用了^_^,生成的zip压缩包可以用winrar等来解压的,当然也可以用php来解压。解压的过段时间再发布了。

<?php

$button=$_POST['button'];

if($button=="开始打包")

{

$zip=newZipArchive();

$filename="./".date("Y-m-d")."_".md5(time())."_jackfeng.zip";

if($zip->open($filename,ZIPARCHIVE::CREATE)!==TRUE){

exit("无法创建<$filename>n");

}

$files=listdir();

foreach($filesas$path)

{

$zip->addFile($path,str_replace("./","",str_replace("","/",$path)));

}

echo"压缩完成,共压缩了:".$zip->numFiles."个文件n";

$zip->close();

}

Functionlistdir($start_dir='.'){

$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;

}

?>

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">

<html>

<head>

<title>在线打包工具</title>

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

</head>

<body>

<formname="form1"method="post"action="">

<hrsize="1">

<h3><ahref="?">在线打包工具</a></h3>

<P><inputtype="submit"name="button"value="开始打包"/></P>

<P>说明:点开始打包,之后,就是耐心等待打包完成了,根据网站文件多少,需要的时间可能会很长。打包完成之后,压缩包会存放在要打包的站点目录下,以<spanstyle='color:red;'>打包时间+不定长随机字符串+jackfeng.zip</span>这样命名,请登陆ftp后下载。</P>

</form>

</body>

</html>

【php 在线打包_支持子目录】相关文章:

xml+php动态载入与分页

php中smarty模板条件判断用法实例

php判断文本文档字符编码

php支持中文字符串分割的函数

用在PHP里的JS打印函数

php实现统计网站在线人数的方法

php 批量查询搜狗sogou代码分享

为php4加入动态flash文件的生成的支持

PHP IDE phpstorm 常用快捷键

php实现在服务器端调整图片大小的方法

精品推荐
分类导航