效果图

 

前台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 2011-03-25 01:32  王庭安  阅读(2274)  评论(3编辑  收藏  举报