<?php
header('Content-type:text/html;charset=utf-8');
if(isset($_POST['submit'])){
if (is_uploaded_file($_FILES['myfile']['tmp_name'])) {
$arr=pathinfo($_FILES['myfile']['name']);
$newName=date('YmdGis').rand(1000, 99999);
if(move_uploaded_file($_FILES['myfile']['tmp_name'], "uploads/{$newName}.{$arr['extension']}")){
echo "上传成功!";
}else {
echo "移动失败!";
}
}else {
exit('不正常呀!');
}
}
?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang
="zh-CN">
<head
>
<title
>上传页面
</title
>
<meta charset
="utf-8" />
</head
>
<body
>
<form action
="" method
="post" enctype
="multipart/form-data">
<input type
="file" name
="myfile"/>
<input type
="submit" name
="submit" value
="开始上传" />
</form
>
</body
>
</html
>
转载请注明原文地址:https://ipadbbs.8miu.com/read-57668.html