有个页面 
上面:2个 固定的FileUpload(全部上传图片)
中间:无限个file(因为要动态添加 所以用File控件,全部为图片)
 HttpFileCollection files = HttpContext.Current.Request.Files;//这句是我用来遍历中间的
下面:2个 固定的FileUpload(一个图片一个flash)因为上中下这3个上传分别保存的路径都不同,而且我打断点的时候  
 HttpFileCollection files = HttpContext.Current.Request.Files;
会把FileUpload的4个控件也给遍历进去。这样会把的上下2部分存到我的中间部分的图片路径里面去
请问:如何才能把这3部分的东西,存到不同的路径里面去。上中下三部分布局可以打乱简单的说就是一个页面有3层 每一层 有若干个File或者FileUpload,如何分别遍历层内的控件,不会越界。

解决方案 »

  1.   

    其实我说的 没那么详细。4个 FileUpload上传的图片路径都不一样(3个不同项目的图片夹跟一个flash文件夹),file多图上传是同一个路径
      

  2.   

    我现在就是想 如何区分遍历单个层里面的file或者FileUpload
      

  3.   

    HttpFileCollection files = HttpContext.Current.Request.Files;
    这个会遍历页面的所有file控件
    可是我只想遍历某一块(div)内的所有file 如何取?
      

  4.   

    DIV加ruant="server"遍历DIV里面的controls
    下面是批量上传的
    <body> 
        <form id="form1" runat="server"> 
        <div> 
        <table style="width: 343px"> 
                <tr> 
                    <td style="width: 100px"> 
                        多文件上传</td> 
                    <td style="width: 100px"> 
                    </td> 
                </tr> 
                <tr> 
                    <td style="width: 100px"> 
                        <asp:FileUpload ID="FileUpload1" runat="server" Width="475px" /> 
                        </td> 
                    <td style="width: 100px"> 
                        </td> 
                </tr> 
                <tr> 
                    <td style="width: 100px"> 
                        <asp:FileUpload ID="FileUpload2" runat="server" Width="475px" /></td> 
                    <td style="width: 100px"> 
                    </td> 
                </tr> 
                <tr> 
                    <td style="width: 100px"> 
                        <asp:FileUpload ID="FileUpload3" runat="server" Width="475px" /></td> 
                    <td style="width: 100px"> 
                    </td> 
                </tr> 
                <tr> 
                    <td style="width: 100px"> 
                        <asp:Button ID="bt_upload" runat="server" OnClick="bt_upload_Click" Text="一起上传" /> 
                        <asp:Label ID="lb_info" runat="server" ForeColor="Red" Width="448px"></asp:Label></td> 
                    <td style="width: 100px"> 
                    </td> 
                </tr> 
            </table> 
        </div> 
        </form> 
    </body>
    using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page  

        protected void Page_Load(object sender, EventArgs e) 
        {     } 
        protected void bt_upload_Click(object sender, EventArgs e) 
        { 
            if (FileUpload1.PostedFile.FileName == "" && FileUpload2.PostedFile.FileName == "" && FileUpload3.PostedFile.FileName == "") 
            { 
                this.lb_info.Text = "请选择文件!"; 
            } 
            else 
            { 
                HttpFileCollection myfiles = Request.Files; 
                for (int i = 0; i < myfiles.Count; i++) 
                { 
                    HttpPostedFile mypost = myfiles[i]; 
                    try 
                    { 
                        if (mypost.ContentLength > 0) 
                        { 
                            string filepath = mypost.FileName;//C:\Documents and Settings\Administrator\My Documents\My Pictures\20022775_m.jpg 
                            string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1);//20022775_m.jpg 
                            string serverpath = Server.MapPath("~/images/") + filename;//C:\Inetpub\wwwroot\WebSite2\images\20022775_m.jpg 
                            mypost.SaveAs(serverpath); 
                            this.lb_info.Text = "上传成功!"; 
                        } 
                    } 
                    catch (Exception ex) 
                    { 
                        this.lb_info.Text = "上传发生错误!原因:" + ex.Message.ToString(); 
                    } 
                } 
            } 
        } 
    }jquery 批量上传插件Uploadify
    参考
      

  5.   

    重点在
    DIV加ruant="server"遍历DIV里面的controls
    就是不知道才问,下面的批量上传我大把  都是
    利用 HttpFileCollection myfiles = Request.Files; 这个不就是遍历页面内所有控件么。
      

  6.   

    看了你的代码 也都是遍历页面所有file控件上传。问题一开始我就说了 
    如何遍历div内的控件。
    你说加个ruant=“server”
    跟问题重复了