查看完整版本: 用 PHP 实现上传的 ZIP 文件的解压

lily 2007-8-1 22:32

用 PHP 实现上传的 ZIP 文件的解压

             <p>#upload.php <BR>&lt;table border='0' &gt; <BR>&lt;form ENCTYPE="multipart/form-data" action="upsave.php" method="post"&gt; <BR><BR>&lt;tr&gt; <BR>&lt;td&gt;如果是*.ZIP的文件会被自动解压缩&lt;br&gt; <BR>&lt;INPUT NAME="MyFile" TYPE="File" size="50"&gt; <BR>&lt;/td&gt; <BR>&lt;/tr&gt; <BR>&lt;tr&gt; <BR>&lt;td colspan='2' align="center"&gt; <BR>&lt;input type="Submit" value=" 上传 " class=iwhite&gt; <BR>&lt;input type="reset" value=" 重填 " class=iwhite&gt; <BR>&lt;/td&gt; <BR>&lt;/tr&gt; <BR>&lt;/table&gt; <BR><BR><BR><BR>&lt;/body&gt; <BR>&lt;/html&gt; <BR><BR><BR>&lt;? <BR>//upsave.php <BR>//保存上传的文件 <BR>$filename="$MyFile_name"; <BR>copy($MyFile,"$filename"); <BR>unlink($MyFile); <BR><BR>//判断是否是ZIP文件 <BR>$expand_name=explode(".",$filename); <BR>if($expand_name[1] == "zip" or $expand_name[1] == "ZIP") <BR>{ <BR>$str="pkunzip.exe -e $filename "; <BR>exec($str); <BR>unlink($filename); <BR>} <BR><BR>?&gt; <BR><BR>以上的程序我已经测试过,只要放在服务器上就可以了,但是该目录要有写的权限。还有一个pkunzip.exe的文件也要放在该目录中,该文件已经放在了压缩包中 <BR></p>     <center><input type="image" onclick=copyToClipBoard() src="http://www.phpchina.com/images/phpcn_book_bu_tj.gif" border="0"></center>
页: [1]
查看完整版本: 用 PHP 实现上传的 ZIP 文件的解压
PageRank