哪位高手有能力帮我改改这个看看可否实现我要的效果?这里看不出应该在哪里上传?
我希望的是不按“浏览”也不按“提交”,只是在其它地方模拟点击而实现上传图片到服务器的效果,但是目前看来给FILE赋值是禁止的,或者会有安全提示,这些都不是我想要的。
<head>
</head>
<body>
<form name=fm1>
<div id=bxAttList>
<div id=bxAtt onmouseover="$('bxAtt1').style.textDecoration='underline'" onmouseout="$('bxAtt1').style.textDecoration=''" style=float:left;width:60>
<span id=bxAtt1 style='position:absolute;padding-top:3;cursor:hand;font-family:宋体'>@添加附件</span>
<span id=bxAtt2 onmouseover=this.scrollLeft=100 style=position:absolute;width:60;overflow:hidden;filter:alpha(opacity=0);-moz-opacity:0></span>
</div>
</div>
</form>
</body>
<script>
file_create()
function file_create(){
$("bxAtt2").innerHTML="<input onchange=file_change(this) hidefocus type=file name=file1 size=1 >"
}
function file_change(tx){
var sName,o
sName=tx.value.replace(/\\/g,"/").replace(/(.*\/)(.*)/,"$2")
o=document.createElement("nobr")
o.style.cssText="float:left;margin-right:6;padding-top:3;color:darkgreen"
o.innerHTML="□"+sName+"<font onclick=$('bxAttList').removeChild(this.parentNode);file_repos() class=hand style=color:red;font-weight:bold>"+unescape("%d7")+"</font>"
tx.style.display="none"
o.appendChild(tx)
$("bxAttList").insertBefore(o,$("bxAtt"))
file_repos()
file_create()
}
function file_repos(){
$("bxAttList").appendChild($("bxAtt"))
}
function $(obj){
return typeof(obj)=="object"?obj:document.getElementById(obj)
}
</script>
</body>
</html>
或者看看修改这个无法赋值错在哪?(模拟点击不用管)<form name="myform" id="frm" action="" method="post" enctype="multipart/form-data"> <input type="text" name="file2" id="file2" readonly="true">
<input type="button" name="Submit" value="Browse" onClick="cc()">
<br />
<input type="file" name="file" id="file1" style="display:block;" onChange="this.form.file2.value=value">
<input type="submit" name="Submit1" value="提交" >
</form>
<script>
function dd()
{
document.getElementById("file2").value="ddddd"
cc()
}function cc()
{
document.myform.form.file1.click();
}
</script>
<input type="submit" name="Submit2" value="提交" onClick="dd()">
我希望的是不按“浏览”也不按“提交”,只是在其它地方模拟点击而实现上传图片到服务器的效果,但是目前看来给FILE赋值是禁止的,或者会有安全提示,这些都不是我想要的。
<head>
</head>
<body>
<form name=fm1>
<div id=bxAttList>
<div id=bxAtt onmouseover="$('bxAtt1').style.textDecoration='underline'" onmouseout="$('bxAtt1').style.textDecoration=''" style=float:left;width:60>
<span id=bxAtt1 style='position:absolute;padding-top:3;cursor:hand;font-family:宋体'>@添加附件</span>
<span id=bxAtt2 onmouseover=this.scrollLeft=100 style=position:absolute;width:60;overflow:hidden;filter:alpha(opacity=0);-moz-opacity:0></span>
</div>
</div>
</form>
</body>
<script>
file_create()
function file_create(){
$("bxAtt2").innerHTML="<input onchange=file_change(this) hidefocus type=file name=file1 size=1 >"
}
function file_change(tx){
var sName,o
sName=tx.value.replace(/\\/g,"/").replace(/(.*\/)(.*)/,"$2")
o=document.createElement("nobr")
o.style.cssText="float:left;margin-right:6;padding-top:3;color:darkgreen"
o.innerHTML="□"+sName+"<font onclick=$('bxAttList').removeChild(this.parentNode);file_repos() class=hand style=color:red;font-weight:bold>"+unescape("%d7")+"</font>"
tx.style.display="none"
o.appendChild(tx)
$("bxAttList").insertBefore(o,$("bxAtt"))
file_repos()
file_create()
}
function file_repos(){
$("bxAttList").appendChild($("bxAtt"))
}
function $(obj){
return typeof(obj)=="object"?obj:document.getElementById(obj)
}
</script>
</body>
</html>
或者看看修改这个无法赋值错在哪?(模拟点击不用管)<form name="myform" id="frm" action="" method="post" enctype="multipart/form-data"> <input type="text" name="file2" id="file2" readonly="true">
<input type="button" name="Submit" value="Browse" onClick="cc()">
<br />
<input type="file" name="file" id="file1" style="display:block;" onChange="this.form.file2.value=value">
<input type="submit" name="Submit1" value="提交" >
</form>
<script>
function dd()
{
document.getElementById("file2").value="ddddd"
cc()
}function cc()
{
document.myform.form.file1.click();
}
</script>
<input type="submit" name="Submit2" value="提交" onClick="dd()">
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货