求多图片上传与显示代码 孟子大哥给出了上传方法,同时我想多图片生成预览和显示,请大家帮忙!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //****后代码 StringBuilder sb = new StringBuilder(); StringBuilder strTemp = new StringBuilder(); int attCount = 0; string filePath = ""; for (int i = 0; i < Request.Files.Count; i++) { if (Request.Files[i].ContentLength > 0) { filePath = Request.Files[i].FileName; sb.Append("Files" + attCount++ + ": " + filePath + "<br>"); Request.Files[0].SaveAs(Server.MapPath("../UpLoadFiles/Temp/") + filePath.Substring(filePath.LastIndexOf("\\") + 1)); //****删除最后一个"," //UpFiles.Value +=filePath.Substring(filePath.LastIndexOf("\\") + 1) + ","; if (UpFiles.Value == "") { UpFiles.Value = Server.MapPath("../UpLoadFiles/Temp/") + filePath.Substring(filePath.LastIndexOf("\\") + 1); } else { UpFiles.Value += "," + Server.MapPath("../UpLoadFiles/Temp/") + filePath.Substring(filePath.LastIndexOf("\\") + 1); } } } sb.Insert(0, "you upload " + attCount + " files.<br>"); Response.Write(sb.ToString()); BuliteTable = AppGloap.UpLoadFiles(UpFiles.Value);//****前台代码 <script language="javascript"> <!-- 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 = "添加附件"; } function CtrlEnter() { if(event.ctrlKey && event.keyCode==13) { alert("cccc"); } } //****显示提示 function On_Windows() { if(form1.WindowsMessageBox.value!="") { //****给出提示 alert(form1.WindowsMessageBox.value); form1.WindowsMessageBox.value=""; } } function DispalyUpLoadFilePath(varFilePath) { form1.UpLoadFilePath.value=varFilePath; } //****不显示右键 //--> </script></head><body onload="On_Windows();"> <form id="form1" enctype="multipart/form-data" runat="server"> <div> <table id="attAchments" align="center"> <tr> <td> <img src="icoAddFl.gif" border="0" algin="absmiddle"> <a id="attach" style="font-family: 宋体; font-size: 9pt;" title="如果您要发送多个附件,您只需多次点击“继续添加附件”即可, 要注意附件总量不能超过发送限制的大小。" onclick="AddAttachments();" href="javascript:;" name="attach">添加附件</a> </td> </tr> </table> <asp:Button ID="btnSend" runat="server" Text=" 上传 " OnClick="btnSend_Click"></asp:Button> <input id="butok" onkeyup="CtrlEnter();" value="Ctrl And Enter" type="button" /> <input id="UpFiles" runat="server" type="hidden" /> <div align="center"> <%=BuliteTable%> </div> <input id="UpLoadFilePath" runat="server" type="hidden" /> <input id="WindowsMessageBox" runat="server" type="hidden" /> </div> </form></body></html> http://msdn.microsoft.com/vstudio/express/vwd/starterkit/#personal下载Personal Web Site。这个就是那个示例 Forms验证 namhyuk兄还在吗,继续求教 怎么防止直接下载文件 为什么在网页中会出一现条Set-Cookie: sid=****** menu的问题 ASP.NET 如何實現圖片不變形縮放? 请问 Jquery 插件Easy UI vs2012 mvc4创建项目运行app_data下没生成数据库 将 numeric 转换为数据类型 numeric 时出现算术溢出错误。 关于TreeView的伸缩问题,高手请指教 工程中的页面中关键字如"浏览"自动加链接到www.aimimi.cn,导致__doPostBack产生错误,请问如何解决?谢谢.
StringBuilder sb = new StringBuilder();
StringBuilder strTemp = new StringBuilder(); int attCount = 0; string filePath = "";
for (int i = 0; i < Request.Files.Count; i++)
{
if (Request.Files[i].ContentLength > 0)
{
filePath = Request.Files[i].FileName;
sb.Append("Files" + attCount++ + ": " + filePath + "<br>"); Request.Files[0].SaveAs(Server.MapPath("../UpLoadFiles/Temp/") + filePath.Substring(filePath.LastIndexOf("\\") + 1)); //****删除最后一个","
//UpFiles.Value +=filePath.Substring(filePath.LastIndexOf("\\") + 1) + ",";
if (UpFiles.Value == "")
{
UpFiles.Value = Server.MapPath("../UpLoadFiles/Temp/") + filePath.Substring(filePath.LastIndexOf("\\") + 1);
}
else
{
UpFiles.Value += "," + Server.MapPath("../UpLoadFiles/Temp/") + filePath.Substring(filePath.LastIndexOf("\\") + 1);
} }
}
sb.Insert(0, "you upload " + attCount + " files.<br>"); Response.Write(sb.ToString()); BuliteTable = AppGloap.UpLoadFiles(UpFiles.Value);
//****前台代码
<script language="javascript">
<!--
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 = "添加附件";
}
function CtrlEnter()
{
if(event.ctrlKey && event.keyCode==13)
{
alert("cccc");
}
}
//****显示提示
function On_Windows()
{
if(form1.WindowsMessageBox.value!="")
{
//****给出提示
alert(form1.WindowsMessageBox.value);
form1.WindowsMessageBox.value="";
}
}
function DispalyUpLoadFilePath(varFilePath)
{
form1.UpLoadFilePath.value=varFilePath;
}
//****不显示右键
//-->
</script></head>
<body onload="On_Windows();">
<form id="form1" enctype="multipart/form-data" runat="server">
<div>
<table id="attAchments" align="center">
<tr>
<td>
<img src="icoAddFl.gif" border="0" algin="absmiddle">
<a id="attach" style="font-family: 宋体; font-size: 9pt;" title="如果您要发送多个附件,您只需多次点击“继续添加附件”即可, 要注意附件总量不能超过发送限制的大小。"
onclick="AddAttachments();" href="javascript:;" name="attach">添加附件</a>
</td>
</tr>
</table>
<asp:Button ID="btnSend" runat="server" Text=" 上传 " OnClick="btnSend_Click"></asp:Button>
<input id="butok" onkeyup="CtrlEnter();" value="Ctrl And Enter" type="button" />
<input id="UpFiles" runat="server" type="hidden" />
<div align="center">
<%=BuliteTable%>
</div>
<input id="UpLoadFilePath" runat="server" type="hidden" />
<input id="WindowsMessageBox" runat="server" type="hidden" />
</div>
</form>
</body>
</html>
下载Personal Web Site。这个就是那个示例