php在windows平台执行shell解压文件

<!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=utf-8" />
<title>无标题文档</title>
</head>

<body>

<form action="" method="post" enctype="multipart/form-data">
选择文件:<input name="myrar" type="file" /><br />
<input name="sub" value="提交解压文件" type="submit"/>
</form>
<?php
if(isset($_POST['sub']))
{
 $datetime=date("Ymdhis");
 $arr=explode(".",$_FILES["myrar"]["name"]);
 $exce=$arr[1];//获取扩展名
 $allowarr=array("rar");//允许上传的扩展名
 if(!in_array($exce,$allowarr)){echo "文件类型不允许";exit();}
 $newname=$datetime.".".$exce;//重命名文件
 $path="rar/" .$newname;
 $a=@move_uploaded_file($_FILES['myrar']['tmp_name'],$path);
 //具体参见php手册,这个是移动文件到$path文件夹下
 if($a){
 //进行解压操作
 echo "上传成功,执行解压。。。";
$obj=new com("wscript.shell");//com组建   加载wscript.shell用来执行dos命令组件
 $dir=getcwd();//获取当前目录路径
 $shell="winrar x $dir\\"."rar"."\\".$newname." $dir";
 $obj->run($shell,1,true);//执行脚本  
 echo "解压成功。。。删除原来压缩包。。。";
 //unlink($path);//删除上传的压缩包
 }
}
 
?>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值