RT
解决方案 »
- 找出不在"<>" 或 "</>"之内的所有空格,正则表达式该怎么写?
- 连接数据库???
- 请问java 实现移动键盘事件要注意哪些问题啊?怎么我这段代码没法子移动标签了?
- java如何批量读取文件
- 从jdk1.5 退到 jdk1.4 的“(Unsupported major.minor version 49.0)”错误
- InputStream接收byte数据问题,请高手指教。
- ----向jTextPane添加滚动条的问题------
- 谁知道怎么能用程序读出控制台输出的内容
- 请介绍一下final的用法。
- csdn论坛列表的浮动菜单是怎么实现的?
- 正则表达式 java.lang.StackOverflowError
- 请教一道java基础问题
js:
function AddAttachments()
{
if(num > 5)
{
alert("最多只能上传五个附件!");
return;
}
num ++;
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)
{
num --;
document.getElementById('attAchments').deleteRow(index);
tb.rows.length > 0?document.getElementById('attach').innerText = "继续添加附件":document.getElementById('attach').innerText = "添加附件";
} html <table id="attAchments">
</table>
<a id="attach" style="font-family: 宋体; font-size: 9pt;" title="如果您要发送多个附件,您只需多次点击“继续添加附件”即可, 要注意附件单个大小不要超过50M。" onclick="AddAttachments();" href="javascript:;" name="attach">添加附件</a>
<asp:TextBox ID="TextBox1" Runat="server" Font-Bold="true" class="rece4" />
<asp:Button ID="btnSend" runat="server" Text=" 上传 " OnClick="btnSend_Click"></asp:Button>后台:
protected void btnSend_Click(object sender, EventArgs e)
{ StringBuilder sb = new StringBuilder(); int attCount = 0; string filePath = ""; string strPath = ""; string Name = "";
string newName = ""; for (int i = 0; i < Request.Files.Count; i++)
{ if (Request.Files[i].ContentLength > 0)
{ filePath = Request.Files[i].FileName; FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read); double d = file.Length / 1024 / 1024; sb.Append("Files" + attCount++ + ": " + filePath + "<br>"); Name = getName(filePath);
newName = getNewName(Name);
strPath = Server.MapPath("~/mailsfile/") + filePath.Substring(filePath.LastIndexOf("\\") + 1).Replace(Name, newName);
//保存文件
Request.Files[0].SaveAs(strPath);
} } //sb.Insert(0, "you upload " + attCount + " files.<br>"); Response.Write(sb.ToString()); }