- index.html
<html>
<head>
<meta charset="utf-8">
<title>图片上传</title>
</head>
<body>
<form action="add.php" method="post" enctype="multipart/form-data">
<label for="file">文件名:</label>
<input type="text" name="name">
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="提交">
</form>
</body>
</html>
- add.php
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "错误:" . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "<pre>";
print_r($_POST); //文本框打印
echo "</pre>";
echo "<pre>