<body>
<form action="" method="post" enctype="multipart/form-data">
<table>
<tr>
<td width="150" height="30" align="right" valign="middle">请选择上传文件:</td>
<td width="250"><input type="file" name="upfile" /></td>
<td width="100"><input type="submit" name="submit" value="上传"/></td>
</tr>
</table>
</form>
<?php
if(!empty($_FILES['upfile'])){
$fileinfo=$_FILES['upfile'];
if($fileinfo['size']<2097152&&$fileinfo['size']>0){
$path="upfile/".$_FILES['upfile']['name'];
move_uploaded_file($fileinfo['tmp_name'],$path);
echo"<script>
alert( '文件上传成功');
</script>";
}else{
echo '文件上传大小不符合要求';
}
}
?>
</body>