本文介绍了该路径不是合法的表单文件上载ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到问题,当我想将文件上传到sql数据库时,它给了我消息

i am facing problem when i want to upload file to sql database it gave me message

The path is not of a legal form. 





我的尝试:





What I have tried:

protected void BtnSaveReply_Click(object sender, EventArgs e)
       {
           FileInfo fi =new  FileInfo(FileUpload1.FileName);
           byte[] Document_Content = FileUpload1.FileBytes;
           string name = fi.Name;
           string Extension = fi.Extension;
           BAL_ObjectsCCRM.BO_Scripts objbo = new BAL_ObjectsCCRM.BO_Scripts();
           objbo.Content_Name = Document_Content;
           objbo.File_Name = name;
           objbo.Extention = Extension;
           Scp.Insert_Script(objbo);


       }





Businness Layer Code



Businness Layer Code

public void Insert_Script(BAL_ObjectsCCRM.BO_Scripts objbo)


       {
           DAL_CCRMUI.DataAccessLayer Dal = new DAL_CCRMUI.DataAccessLayer();
           Dal.Open();
           SqlParameter[] param = new SqlParameter[3];
           param[0] = new SqlParameter("@Content_Name", SqlDbType.NVarChar,200)
           {
               Value = objbo.File_Name
           };
           param[1] = new SqlParameter("@Document_Content", SqlDbType.VarBinary,5000)
           {
               Value = objbo.Content_Name
           };
           param[2] = new SqlParameter("@Extension", SqlDbType.NVarChar,10)
           {
               Value = objbo.Extention

           };

           Dal.ExecuteProcedure("Save_Document", param);
           Dal.Close();

       }



商业对象层




Business objbect Layer

public class BO_Scripts
   {
       public string  File_Name { get; set; }
       public Byte[] Content_Name { get; set; }
       public string  Extention { get; set; }


   }

推荐答案


这篇关于该路径不是合法的表单文件上载ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 15:46