HTML代码:

<html>
<body>
<form action="post.php" method="post" enctype="multipart/form-data">
<label for="file">file name:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="submit" />
</form>
</body>
</html>

PHP代码:

<?php
$file=$_FILES["file"];
$arr=explode(".",$file['name']);
$ext=$arr[count($arr)-1];
unset($arr);
if($ext!="zip" && $ext!="rar" &&$ext!="7z"){

}else{
rename($file["tmp_name"],'./upload/'.time().".".$ext);
}

Related Posts: PHP-上传文件示例 :