html构造表单
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form method="post" action="upload_file.php" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="上传"/>
</form>
</body>
</html>
php构造上传
<?php
$arr = $_FILES["file"];
$filename="./upload/".$arr["name"];
$filename = iconv("UTF-8","gb2312",$filename);
move_uploaded_file($arr["tmp_name"],$filename);
if ($_FILES["file"]["error"] > 0)
{
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"];
}
?>