诡异~~ASP.NET 程序 无法上传文件 (这个..自己大意造成的嘛~~)

现在VS自带的ASP.NET 服务器也不管用鸟、、·~

 

系统也还原过,另一个程序则没有这样的问题,

如图:Request.Files.AllKeys.Count始终为0

开始以为是没有更新生成代码,页面名称和页面类名称也换过 问题依旧,

后来使用VS自带的ASP.NET服务器进行调试没有问题。。。

文件目录权限也都给了上传控件使用的是<input type="file" />并且放在Table里,

也换过Server Control ,如果是服务器控件的话选择文件提交后调试发现控件的FileName属性为空。。

 

另外:还是这个页面之前遇到过表单填写的内容提交到后台居然全是空。。然后莫名其妙的好了,现在只剩下文件这块

 

         < tr >
            
< td  height ="25"  width ="30%"  align ="right" >
                项目照片 :
            
</ td >
            
< td  height ="25"  id ="profiles"  width ="*"  align ="left" >
                
< asp:FileUpload  ID ="FileUpload1"  runat ="server"   />
                
< br  />
                
< input  id ="File2"  type ="file"   />
                
< br  />
                
< input  id ="File3"  type ="file"   />
                
< br  />
                
< input  id ="File4"  type ="file"   />
                
< br  />
            
</ td >
        
</ tr >

 

 

ExpandedBlockStart.gif 后台代码
        // 上传图片
        
        HttpFileCollection files 
=  Request.Files;
        
string  filexts  =   " .jpg.jepg.png " ;
        
for  ( int  i  =   0 ; i  <  files.Count; i ++ )
        {
            
// 最大一兆,大于1M的将会被忽略
             if  (filexts.Contains(System.IO.Path.GetExtension(files[i].FileName).ToLower())  &&  files[i].ContentLength  <   1024   *   1024 )
            {
                files[i].SaveAs(
string .Format(Server.MapPath( " /Tendersimg/{0}/{1} " ), model.ID, files[i].FileName));
            }
        }
        FileUpload1.SaveAs(
string .Format(Server.MapPath( " /Tendersimg/{0}/{1} " ), model.ID, FileUpload1.FileName));        

 即时调试信息:

分别输出了Request.Form["File2"],FileUpload1和Request.Files 

ExpandedBlockStart.gif 代码
Request.Form[ " File2 " ]
null
FileUpload1
{System.Web.UI.WebControls.FileUpload}
    
base  {System.Web.UI.WebControls.WebControl}: {System.Web.UI.WebControls.FileUpload}
    FileBytes: {
byte [ 0 ]}
    FileContent: {System.IO.Stream.NullStream}
    FileName: 
""
    HasFile: 
false
    PostedFile: 
null
Request.Files
{System.Web.HttpFileCollection}
    
base  {System.Collections.Specialized.NameObjectCollectionBase}: {System.Web.HttpFileCollection}
    AllKeys: {
string [ 0 ]}

 

 貌似找到原因了。。。

这个项目使用了别人的源码。。

他在web.config里配置了HttpUploadModule......

        <httpModules>
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add name="HttpUploadModule" type="X.Upload.HttpUploadModule, X.Upload" />
            <add name="Spaces" type="X.XHttpModule, x" />
        </httpModules>

 

 

转载于:https://www.cnblogs.com/Qbit/archive/2010/07/07/1772663.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值