请知悉:本文最近一次更新为 7年 前,文中内容可能已经过时。

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);
}

如您从本文得到了有价值的信息或帮助,请考虑扫描文末二维码捐赠和鼓励。

尊重他人劳动成果。转载请务必附上原文链接,我将感激不尽。


与《PHP-上传文件示例》相关的博文:


留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌