效果图
前台aspx页面(UploadPage.aspx)
<script language="javascript" type="text/jscript">
function DocumentUpload()
{
window.document.getElementById("idUploadCtl").MultipleUpload();
}
</script>
<form id="form1" runat="server">
<input type="hidden" name="Cmd" value="Save" />
<input type="hidden" name="putopts" value="true" />
<input type="hidden" name="Confirmation-URL" Value="<%= this.Confirmation_URL%>" />
<input type="hidden" name="PostURL" Value="<%= this.PostURL%>" />
<input type="hidden" name="VTI-GROUP" value="0" />
<div style="width:700px;border:solid 1px #909090;">
<script>
try
{
var a = new ActiveXObject("Name.NameCtrl.1");
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (new ActiveXObject("STSUpld.UploadCtl"))
{
document.write("<OBJECT id=idUploadCtl name=idUploadCtl CLASSID=CLSID:07B06095-5687-4d13-9E32-12B4259C9813 WIDTH='100%' HEIGHT='350px'></OBJECT>");
}
}
catch (error) { }
</script>
</div>
<div style="margin-top:10px;">
<input id="Button1" type="button" value="button" onclick="DocumentUpload();" />
</div>
</form>
function DocumentUpload()
{
window.document.getElementById("idUploadCtl").MultipleUpload();
}
</script>
<form id="form1" runat="server">
<input type="hidden" name="Cmd" value="Save" />
<input type="hidden" name="putopts" value="true" />
<input type="hidden" name="Confirmation-URL" Value="<%= this.Confirmation_URL%>" />
<input type="hidden" name="PostURL" Value="<%= this.PostURL%>" />
<input type="hidden" name="VTI-GROUP" value="0" />
<div style="width:700px;border:solid 1px #909090;">
<script>
try
{
var a = new ActiveXObject("Name.NameCtrl.1");
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if (new ActiveXObject("STSUpld.UploadCtl"))
{
document.write("<OBJECT id=idUploadCtl name=idUploadCtl CLASSID=CLSID:07B06095-5687-4d13-9E32-12B4259C9813 WIDTH='100%' HEIGHT='350px'></OBJECT>");
}
}
catch (error) { }
</script>
</div>
<div style="margin-top:10px;">
<input id="Button1" type="button" value="button" onclick="DocumentUpload();" />
</div>
</form>
后台cs页面(UploadPage.aspx.cs)
public string Confirmation_URL = string.Empty;
public string PostURL = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
this.Confirmation_URL = "http://localhost:2467/default.aspx";
this.PostURL = "http://localhost:2467/Upload.aspx?ext=big";
}
public string PostURL = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
this.Confirmation_URL = "http://localhost:2467/default.aspx";
this.PostURL = "http://localhost:2467/Upload.aspx?ext=big";
}
接收上传文件的页面代码(Upload.aspx.cs)
protected void Page_Load(object sender, EventArgs e)
{
if (this.Request.Files.Count > 0)
{
string path = this.Server.MapPath("~/UploadFiles");
for (int i = 0; i < this.Request.Files.Count; i++)
{
HttpPostedFile file = this.Request.Files[i];
string fileName = System.IO.Path.Combine(path, System.IO.Path.GetFileName(file.FileName));
file.SaveAs(fileName);
}
}
}
{
if (this.Request.Files.Count > 0)
{
string path = this.Server.MapPath("~/UploadFiles");
for (int i = 0; i < this.Request.Files.Count; i++)
{
HttpPostedFile file = this.Request.Files[i];
string fileName = System.IO.Path.Combine(path, System.IO.Path.GetFileName(file.FileName));
file.SaveAs(fileName);
}
}
}
这个就是MOSS中传说的上传多个文件的控件,好用啊,哈哈。。。
貌似还没有人给过一个完整可用的代码示例。。。奇怪。。。
老衲只好献丑了,哦弥陀佛。。。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?