有你在真好 的个人博客
HttpContext.Current.Request.Files后台取不到值的解决方法
阅读:2669 添加日期:2021/3/22 16:07:19
"

上传文件的东东, 

前台是3个INPUT: 
<INPUT   style= "WIDTH:   480px;   HEIGHT:   22px "   type= "file "   name= "File "   size= "60 "> 
<INPUT   style= "WIDTH:   480px;   HEIGHT:   22px "   type= "file "   name= "File "   size= "60 "> 
<INPUT   style= "WIDTH:   480px;   HEIGHT:   22px "   type= "file "   name= "File "   size= "60 "> 

在后台遍历 
HttpFileCollection   files     =   HttpContext.Current.Request.Files; 
int   mm   =   files.Count;

结果:
mm   =0;


可能有几种原因,针对这些原因有如下方法:

一、form   的enctype不对. 要加入enctype= "multipart/form-data "

二、手工加这个或者至少放一个runat= 'server '的file控件在窗体中.

三、form中用了AJAX,如果没有必要用,就不要随处放updatePannel控件


"
ICP备案号:苏ICP备14035786号-1 苏公网安备 32050502001014号