求一段FileUpload上传图片或文本附件 到SQL2000 数据库的代码 谢谢!在线等 解决散分
求一段FileUpload上传图片或文本附件 到SQL2000 数据库的代码 谢谢!在线等 解决散分
要求根据上传附件类型 判断类型 然后把图片或文本插入到数据库中image或text字段  
------解决方案--------------------
if (this.FileUpload1.HasFile)//如果第一个控件有文件
               {                  
                   string name = this.FileUpload1.FileName;//获取上传文件名
                   string ipath = Server.MapPath("updata" + "\\" + name);//获得实际路径
                   nic.Access = "updata\\" + name;//传到数据库里的虚拟路径
                   string type = this.FileUpload1.PostedFile.ContentType;
                   if (type == "image/gif" || type == "image/pjpeg" || type == "application/octet-stream" || type == "application/zip" || type == "application/msword" || type == "application/vnd.ms-excel" || type == "text/plain" || type == "application/pdf")
                   {
                       try
                       {
                           this.FileUpload1.SaveAs(ipath);
                       }
                       catch (Exception ee)
                       {
                           this.Label4.Text = ee.Message.ToString();
                           return;
                       }
                   }
                   else
                   {
                       Response.Write("<script>alert('上传的文件类型不对,请重新选择!')</script>");
                       //this.Label4.Text = "上传的文件类型不对,请重新选择";
                       return;
                   }
               }