后置代码
if (Request.Form["Photo"] != null)
        {
            Response.Write(Request.Form["Photo"]);
            Response.End();
        }前台页面
<input name="Photo" type="file" id="Photo" />取不到值。没有数据打印出来

解决方案 »

  1.   

    我试了你的代码,当我选择了一个要上传的文件,点击Sumbit按钮时可以再页面上显示了我在本地要上传文件的绝对的地址
      

  2.   

    Request.Form 获取表单的值,应该是要提交才能获取值的
      

  3.   

    你是做 asp 吗?
    是不是表单的提交方式不对?
      

  4.   

    在form里加encType="multipart/form-data" 
      

  5.   

      是不是 提交方式 有问题
        建议 换成 POST
      

  6.   


    你这是文件上传控件,取值不能像你这种写法吧.HttpPostedFile uf=Request.Files["Photo"];
    uf.SaveAs(Request.MapPath(Path.GetFileName(uf.FileName)));
      

  7.   

    上传控件应该用Request.Files来获取
      

  8.   

    需要本页回传,而不是本页回发。
    用url传吧
      

  9.   

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
           Response.Write(Request.Form["Photo"]); 
        }
    }
    此时才能取到值;
      

  10.   

     HttpFileCollection files = HttpContext.Current.Request.Files; ///'遍历File表单元素
      for (int iFile = 0; iFile < files.Count; iFile++)
       {
               HttpPostedFile postedFile = files[iFile];
            
               string fileName = System.IO.Path.GetFileName(postedFile.FileName);
    Response.Write(fileName )
       } 
    楼主那样的是获取从别的页面提交过来的表单
      

  11.   

    <input name="Photo" type="file" id="Photo"  name="Photo"/
      

  12.   

    你在input 里加上runat=server,直接用input的ID.value获取值