posts - 21,comments - 64,views - 25007

效果图

 

前台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>
复制代码


 后台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";
        }
复制代码

 


接收上传文件的页面代码(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);
                }

                
            }
        }
复制代码


       


这个就是MOSS中传说的上传多个文件的控件,好用啊,哈哈。。。
貌似还没有人给过一个完整可用的代码示例。。。奇怪。。。
老衲只好献丑了,哦弥陀佛。。。

posted on   王庭安  阅读(2284)  评论(3编辑  收藏  举报
编辑推荐:
· 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,谁才是开发者新宠?
< 2011年3月 >
27 28 1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2
3 4 5 6 7 8 9

点击右上角即可分享
微信分享提示