把文件域隐藏,用按钮实现上传文件的功能,但是在ie浏览器上却接收不到文件的值,ff却能接收到
怎么回事呀?
我用的是smarty<!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>
<script>
function picture(){
document.getElementById('pic').click();
}
</script>
<body><form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input name="pic" id="pic" type="file" style="display:none;"/>
<a href="javascript:picture()">图片</a>
<input name="ac" type="hidden" value="file" />
<input name="" type="submit" value="提交" />
</form></body>
</html>
if(isset($_POST['ac']) && $_POST['ac']=='file'){
echo '<pre>';
print_r($_FILES['pic']);
}
ie里面是错误的,并且还得点两下按钮才提交
Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)ff是对的
怎么回事呀?
我用的是smarty<!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>
<script>
function picture(){
document.getElementById('pic').click();
}
</script>
<body><form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input name="pic" id="pic" type="file" style="display:none;"/>
<a href="javascript:picture()">图片</a>
<input name="ac" type="hidden" value="file" />
<input name="" type="submit" value="提交" />
</form></body>
</html>
if(isset($_POST['ac']) && $_POST['ac']=='file'){
echo '<pre>';
print_r($_FILES['pic']);
}
ie里面是错误的,并且还得点两下按钮才提交
Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)ff是对的
function picture(){
document.getElementById('pic').click();
}
function addFile(file){
//if IE
var input = "<input type='file' name='pic1' value='C:\Documents and Settings\Administrator\桌面\123.gif'>";
document.getElementById("div").innerHTML = input;
}
</script><form action="test.php" method="post" enctype="multipart/form-data" id="form">
<input name="pic" id="pic" type="file" onchange="addFile(this)"><div id="div"></div>
<a href="javascript:picture()">图片</a>
<input name="" type="submit" value="提交">
</form>自己理解去吧