原帖如下:http://community.csdn.net/Expert/topic/4896/4896855.xml?temp=.7850916现在的问题是:我想要一个如下图所示的效果:http://www.yibaiban.com/demo1.gif因为在后台 .cs 文件中取得前台上传文件代码是这样的:HttpFileCollection fileList = HttpContext.Current.Request.Files;
(就是说,他把前台所有文件统一并入这个文件集合中了,)所以当发布信息时,无法分清那些上传文件所属类别是属于效果图,还是属于室外图,要怎么才能分别处理这两组上传文件呢?我把后台文件贴出来:private void MultiFileUpload() // 这个是上传效果图的
{
   HttpFileCollection fileList = HttpContext.Current.Request.Files;   for(fileIndex = 0; fileIndex < fileList.Count; fileIndex++)
    {
      HttpPostedFile postedFile = fileList[fileIndex];
      //然后做上传处理
    }}private void MultiFileUpload2() //这个是上传室外图的
{
   HttpFileCollection fileList = HttpContext.Current.Request.Files;   for(fileIndex = 0; fileIndex < fileList.Count; fileIndex++)
    {
      HttpPostedFile postedFile = fileList[fileIndex];
      //然后做上传处理
    }}因为取得上传文件全是这样处理的HttpFileCollection fileList = HttpContext.Current.Request.Files;我就没法分清哪 些文件是我要取得的那个类别里的

解决方案 »

  1.   

    use different names on the client side,say, for dynamic <input type=file>, then in your cs code, do something likestring[] inputNames = Request.Files.AllKeys;
    for (int i = 0; i < inputNames.Length; i++) 
    {
      if (inputNames[i].IndexOf("title")>= 0)
       Response.Write("File: " + Server.HtmlEncode(inputNames[i]) + " size:" + 
    Request.Files[inputNames[i]].ContentLength +  "<br>");
         
    }
      

  2.   

    谢谢思归大哥:现在就差一点了!!
    string[] inputNames = Request.Files.AllKeys;
    for (int i = 0; i < inputNames.Length; i++) 
    {
      if (inputNames[i].IndexOf("title")>= 0)
      {
           HttpPostedFile postedFile = inputNames[i]; //我想这样做,然后处理上传文件
      }
           
    }可是这句话有错啊:vs.net 提示:无法将类型“string”隐式转换为“System.Web.HttpPostedFile”要怎么办呢?HttpPostedFile postedFile = inputNames[i]; 
      

  3.   

    inputNames[i] is a string, to get the HttpPostedFile, doHttpPostedFile postedFile = Request.Files[inputNames[i]];