文件上载不显示页面加载值 [英] File Upload not Show Value on Page Load

查看:109
本文介绍了文件上载不显示页面加载值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里错误就像文件上传显示空值按钮保存点击。告诉我我要做些什么来解决这个问题。

  if (fluplogo.HasFile) //  此处文件上传的值为空 
{
string FilePath = ;
string [] a = new string [ 1 ];
string fileName = ;
string FullName = ;
尝试
{
如果(fluplogo.FileName.Length < span class =code-keyword>>
0
{
a = fluplogo.FileName.Split(' 。');
fileName = Convert.ToString(System.DateTime.Now.Ticks)+ + a.GetValue( 1 )。ToString();
FilePath = Server.MapPath( @ 〜\ InstituteLogo);
fluplogo.SaveAs(FilePath + @ \ + fileName);

FullName = FilePath + @ \ + fileName;
// 数据库保存文件名操作。

}
}
catch
{
}
}

解决方案

尝试使用以下代码行代替您有问题的行,您将获得空值。希望您的问题得到解决。





 if(fluplogo.PostedFile!= null&&& fluplogo.PostedFile.ContentLength> 0)


Here Error is like that File Upload show null value on Button Save Click.Tell Me what I have to do to fix this.

if (fluplogo.HasFile)//Here  Value of File upload  Is Null
        {
            string FilePath = "";
            string[] a = new string[1];
            string fileName = "";
            string FullName = "";
            try
            {
                if (fluplogo.FileName.Length > 0)
                {
                    a = fluplogo.FileName.Split('.');
                    fileName = Convert.ToString(System.DateTime.Now.Ticks) + "." + a.GetValue(1).ToString();
                    FilePath = Server.MapPath(@"~\InstituteLogo");
                    fluplogo.SaveAs(FilePath + @"\" + fileName);

                    FullName = FilePath + @"\" + fileName;
                    // Database Save Operation of filename.

                }
            }
            catch
            {
            }
        }

解决方案

Try to use the following line of code in place of your problematic line where you are getting null value.. hope your problem gona solve.


if (fluplogo.PostedFile != null && fluplogo.PostedFile.ContentLength > 0)


这篇关于文件上载不显示页面加载值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆