在线等待.net多图片上传问题,请教高手。急
前台js:
<script language= "javascript " type= "text/javascript ">
function AddPhoto()
{
var index = Math.floor(Math.random() * 100000000);
var str= ' <input type=\ "file\ " name=\ "file\ " id=\ " '+index+ '\ " style=\ "position:absolute;filter:alpha(opacity=0);\ " size=\ "1\ "> '
document.getElementById( 'aaa ').insertAdjacentHTML( "beforeEnd ",str);
document.getElementById(index).click();
var PhotoURL= " ";
PhotoURL = document.getElementById(index).value;
if(PhotoURL == " ")
{
alert( "请选择要上传的图片! ");
return false;
}
else
{
var str= ' <img id\ "kkk\ " src=\ " '+PhotoURL+ '\ " width=\ "120\ " height=\ "120\ " /> '
document.getElementById( 'pic_space_main ').insertAdjacentHTML( "beforeEnd ",str);
}
}
前台显示代码:
<td colspan= "2 " align= "center "> <div id= "pic_space_main "
style= "OVERFLOW-X: hidden; WIDTH: 500px; HEIGHT: 350px " align= "left "
valign= "top "> </div> </td>
<input type= "button " value= "浏览本地图片 " class= "fg_btn " onclick= "AddPhoto(); " size= " "> </td>
<td width= "152 " align= "center " style= "height: 24px "> <asp:Button ID= "Upload " runat= "server " class= "fg_btn " Text= "确认上传图片 " OnClick= "Button1_Click " /> </td>
现在的问题是我上传的时候 保存不了js生成的File控件中的图片地址。
查了好多帖子都没解决
[解决办法]
http://dotnet.aspx.cc/ShowDetail.aspx?id=58EA3515-36F2-4FD9-AC89-EAF49F59816C
[解决办法]
<%@ Page language= "c# " Codebehind= "MultiAttchments.aspx.cs " AutoEventWireup= "false " Inherits= "WebApplication3.MultiAttchments " %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN " >
<HTML>
<HEAD>
<script>
function AddAttachments()
{
document.getElementById( 'attach ').innerText = "继续添加附件 ";
tb = document.getElementById( 'attAchments ');
newRow = tb.insertRow();
newRow.insertCell().innerHTML = " <input name= 'File ' size= '50 ' type= 'file '> <input type=button value= '删除 ' onclick= 'delFile(this.parentElement.parentElement.rowIndex) '> ";
}
function delFile(index)
{
document.getElementById( 'attAchments ').deleteRow(index);
tb.rows.length > 0?document.getElementById( 'attach ').innerText = "继续添加附件 ":document.getElementById( 'attach ').innerText = "添加附件 ";
}
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id= "form1 " method= "post " runat= "server " enctype= "multipart/form-data ">
<div> <table id= "attAchments "> </table> </div> <span> <IMG src= "icoAddFl.gif "> </span> <A id= "attach " style= "font-family:宋体;font-size:9pt; " title= "如果您要发送多个附件,您只需多次点击“继续添加附件”即可, 要注意附件总量不能超过发送限制的大小。 " onclick= "AddAttachments(); "
href= "javascript:; " name= "attach "> 添加附件 </A>
<br> <br> <br> <br> <br> <br>
<asp:Button id= "btnSend " runat= "server " Text= " 上传 "> </asp:Button>
</form>
</body>
</HTML>