.net 后台获取file的路径,还要按name区分开!怎么解决!

2025-03-28 16:04:09
推荐回答(3个)
回答1:

string []upfiles = Request.Files.AllKeys;

        string filenames = "";

        foreach (string s in upfiles)
        {
            if (s == "txt")
            {
 
            }
            else if (s == "txt1")
            {
 
            }
            filenames += s+"
";
        }

        Response.Write(filenames);



........................注意:你的是 .NET 后台获取。

估计你是获取不到的。因为你的上传的都是 html,而不是asp.net 控件。

你可以使用.NET fileuploader 控件。

  

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>





    无标题页


    
    

    
        
        
        
        
        
        
    

    
    

 


根据

 foreach (string s in upfiles)
        {
            if (s == "txt")
            {
  
            }
            else if (s == "txt1")
            {
  
            }
            filenames += s+"";
        }

来得到你想要的 上传文件。。

回答2:

定义一个string [] s
然后s[i]=Request.Files[i].FileName;

回答3:

定义一个string [] 这样看看