HTML表单制作,上传到服务器

表单:

info.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

</head>
<body>
	<div align="center">
		<form action="result.php" method="post" name="myform" target="new"
			enctype="multipart/form-data">
			<table border="1" width="500" cellpadding="2">
				<caption>个人信息</caption>
				<tr>
					<td align="right">姓名:</td>
					<td><input name="name" type="text"></td>
				</tr>
				<tr>
					<td align="right">性别:</td>
					<td>男:<input name="sex" type="radio" value="man"> 女:<input
						name="sex" type="radio" value="woman">
					</td>
				</tr>
				<tr>
					<td align="right">爱好:</td>
					<td>
						<p>
							<label> <input type="checkbox" name="like[]" value="book"
								id="like_0"> 看书
							</label> <label> <input type="checkbox" name="like[]"
								value="walk" id="like_1"> 散步
							</label> <label> <input type="checkbox" name="like[]"
								value="play" id="like_2"> 玩耍
							</label> <label> <input type="checkbox" name="like[]"
								value="travel" id="like_3"> 旅游
							</label>

						</p>
					</td>
				</tr>
				<tr>
					<td align="right">学历:</td>
					<td><select name="xueli">
							<option value="xiaoxue">小学</option>
							<option value="chuzhong">初中</option>
							<option value="gaozhong">高中</option>
							<option value="daxue">大学</option>
					</select></td>
				</tr>
				<tr>
					<td align="right">照片:</td>
					<td><input name="photo" type="file"></td>//上传图片
				</tr>
				<tr>
					<td colspan="2" align="center"><input name="submit"
						type="submit" value="提交">   <input name="submit"
						type="reset" value="重置"></td>
				</tr>
			</table>

		</form>
	</div>
</body>
</html>

效果图:

服务器:

 result.php

<!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>
	<table border="1" width="300">
		<tr>
			<td>姓名:</td>
			<td><?php echo  $_POST["name"]?></td>
		</tr>
		<tr>
			<td>性别:</td>
			<td><?php echo  $_POST["sex"]?></td>
		</tr>
		<tr>
			<td>爱好:</td>
			<td><?php
			$re = "";
			if ($_POST ["like"] != null) {
				
				for($i = 0; $i < count ( $_POST ["like"] ); $i ++) {
					$re .= $_POST ["like"] [$i];
				}
			}
			echo $re;
			?></td>
		</tr>
		<tr>
			<td>学历</td>
			<td>
		  <?php
				echo $_POST ["xueli"];
				?>
		     
		  </td>
		</tr>
		 <tr>
		   <td>
		   <?php
		    
		   
		     $path="./upload/".$_FILES["photo"]["name"];
		     move_uploaded_file($_FILES["photo"]["tmp_name"], $path);
		     echo $path
		   
		   ?>
		   </td>
		 </tr>
	</table>


</body>
</html>



郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。