<!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>
</head>
<body>
<b>上传文件处理</b><hr />
<?php
if(isset($_FILES['userfile']))// 按下提交按钮
{
$uploaddir = 'D:/upload';//上传文件放置的路径
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)){//上传文件到指定目录
echo "文件上传成功!\n";
}else{
echo "文件上传失败!\n";
}
echo"这里是上传的一些信息:\n";
print_r($_FILES);
print"</pre>";
die();
}
?>
<b>上传表单</b>
<form enctype="multipart/form-data" action="upload.php" method="post">
<!--MAX_FILE_SIZE 必须在所有的input 域之前-->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
上传的文件:
<input type="file" name="userfile"/>
<input type="submit" value="上传文件"/>
</form>
</body>
</html>