标签:doctype img har 状态码 图片 frame value pre 用户名
方法一:
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a href="./add.php">投票</a>
</body>
</html>
<?php $num = file_get_contents(‘./num.txt‘); $num = intval($num) + 1; file_put_contents(‘./num.txt‘, $num); header(‘HTTP/1.1 204 No Content‘);
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="button" value="投票" id="addBtn" />
<div id="request"></div>
</body>
<script type="">
var addBtn = document.getElementById("addBtn");
addBtn.onclick = function() {
//创建img标签
var img = document.createElement("img");
//设置标签src属性
img.setAttribute("src", "add.php");
document.createElement("request").appendChild(img);
};
</script>
</html>
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<form action="ret.php" method="post" target="request">
用户名:<input type="text" name="uname" value="" />
密码:<input type="password" name="upwd" value="" />
<input type="submit" name="submit" value="提交" />
</form>
<iframe width="0" height="0" frameborder="0" name="request"></iframe>
<div id="result"></div>
</body>
</html>
<?php
$uname = !empty($_POST[‘uname‘]) ? $_POST[‘uname‘] : ‘‘;
$upwd = !empty($_POST[‘upwd‘]) ? $_POST[‘upwd‘] : ‘‘;
if($uname == ‘admin‘ && $upwd == ‘123456‘) {
echo "<script>parent.document.getElementById(‘result‘).innerHTML=‘OK‘;</script>";
} else {
echo "<script>parent.document.getElementById(‘result‘).innerHTML=‘NO‘;</script>";
}
1、iframe 2、flash实现,如swfupload 3、html5 (添加了文件读取api,使ajax上传文件成为可能。)
标签:doctype img har 状态码 图片 frame value pre 用户名
原文地址:http://www.cnblogs.com/jkko123/p/6352068.html