HTML
<html>
<head>
<meta charset = "utf-8">
</head>
<body>
<form action = "up.php" method = "post"enctype="multipart/form-data">
<input type = "submit" value = "点击">
<input type = "file" name = "file" >
</form>
</body>
</html>
php
<?php
if ($_FILES["file"]["error"] > 0)//file 在html的表单中定义,需要method 和 encty$
{
echo "错误:" . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "上传文件名: " . $_FILES["file"]["name"] . "<br>";
echo "文件类型: " . $_FILES["file"]["type"] . "<br>";
echo "文件大小: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "文件临时存储的位置: " . $_FILES["file"]["tmp_name"];
move_uploaded_file($_FILES["file"]["tmp_name"], "up/" . $_FILES["file"]["n$
echo "<br>". "文件存储在: " . "upload/" . $_FILES["file"]["name"];
}
?>