lily 2007-8-1 22:32
用 PHP 实现上传的 ZIP 文件的解压
<p>#upload.php <BR><table border='0' > <BR><form ENCTYPE="multipart/form-data" action="upsave.php" method="post"> <BR><BR><tr> <BR><td>如果是*.ZIP的文件会被自动解压缩<br> <BR><INPUT NAME="MyFile" TYPE="File" size="50"> <BR></td> <BR></tr> <BR><tr> <BR><td colspan='2' align="center"> <BR><input type="Submit" value=" 上传 " class=iwhite> <BR><input type="reset" value=" 重填 " class=iwhite> <BR></td> <BR></tr> <BR></table> <BR><BR><BR><BR></body> <BR></html> <BR><BR><BR><? <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>?> <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>