<?php
if(isset($_POST['submit'])){
  if(is_uploaded_file($_FILES['myfile']['tmp_name'])){
    move_uploaded_file($_FILES['myfile']['tmp_name'],'fileupload/'.$_FILES['myfile']['name']);
  }else{
    header("Location:upload1.php");
  }
}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>上传文件</title>
<style type="text/css">
#divUpload
{
border:1px #7F5125 dotted;
width:900px;
margin:0 auto;
padding:10px;
background-color:#ffefdf;
}
#divUpload h1
{
font-family:Arial;
color:#7F5125;
}
</style>
</head>
<body>
  <div id="divUpload">
  <h1>File Uploader</h1>
  <form    enctype="multipart/form-data" method="post" action="">
        <label>
          <input type="file" name="myfile"/>
        </label>
    <input type="submit" name="submit" value="开始上传" />
  </form>
  </div>
</body>
</html>
<?php } ?>



很简单,运行结果: