<?php
header('Content-type:text/html;charset=utf-8');
// $path= pathinfo($_FILES['myfile']['name']);
// echo $path['extension'].'<br>';
if(isset($_POST['submit'])){
if(is_uploaded_file($_FILES['myfile']['tmp_name'])){
$arr=pathinfo($_FILES['myfile']['name']);
$newName= date('YmdGis').rand(1000,9999);
$fileupdate= date('Ymd').rand(1000,9999);
$fileupname= mkdir("upload/{$fileupdate}");
if(move_uploaded_file($_FILES['myfile']['tmp_name'], "upload/{$fileupdate}/{$newName}.{$arr['extension']}")){
echo '恭喜你上传成功';
} else {
echo '上传失败';
}
}else{
exit('可能有攻击,请遵守法律!');
}
}
?>
<! DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>上传页面</title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="myfile" />
<input type="submit" name="submit" value="开始上传"/>
</form>
</body>
</html>