Home  >  Article  >  Backend Development  >  php下传压缩同时解压文件

php下传压缩同时解压文件

WBOY
WBOYOriginal
2016-06-13 13:12:07864browse

php上传压缩同时解压文件

<?php
header("content-type:text/html; charset=utf-8");
$dir=getcwd();
$time=date('Ym');
if ($_POST[sub]){
	$tname=$_FILES[upfiles][tmp_name];
	$nname=$_FILES[upfiles][name];
	if(!file_exists($time))
		mkdir($time);
	move_uploaded_file($tname, $dir."/".$time."/".$nname);
	$dir=$dir."/".$time;
	$obj=new com("wscript.shell");		//实例化DOS命令的组件
	$obj->run("winrar x $dir/".$nname." ".$dir,1,true);		//run方法 true返回的结果
	unlink($dir."/".$nname);		//删除压缩文件

}
?>
<form action="" method="POST" enctype="multipart/form-data">
选择上传文件<input type="file" name="upfiles"/>
<input type="submit" name="sub" value="提交并解压"/>
</form>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn