上传图片至数据库
来源:互联网 发布:我知这世界本如 知乎 编辑:程序博客网 时间:2024/04/28 00:39
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class addtask : System.Web.UI.Page
...{
static int id;
protected void Page_Load(object sender, EventArgs e)
...{
if (Session["id"] == null)
...{
Response.Redirect("Default.aspx");
}
else
...{
if (Session["IsMain"].ToString() == "1")
...{
}
else
...{
if (Session["IsMain"].ToString() == "2")
...{
}
else
...{
Response.Redirect("Default.aspx");
}
}
}
if (!this.IsPostBack)
...{
id = Convert.ToInt32(Request.QueryString["id"]);
DataSet ds = Custmer.SelCustmer(id);
this.Label15.Text = ds.Tables[0].Rows[0][1].ToString();
this.Label16.Text = ds.Tables[0].Rows[0][2].ToString();
ds.Clear();
this.Panel1.Visible = true;
this.Panel2.Visible = false;
this.Panel3.Visible = false;
this.Badd.Attributes["onclick"] = "javascript:jump();";
}
}
protected void Badd_Click(object sender, EventArgs e)
...{
DataSet ds = Custmer.SelCustmer(id);
int iOperatorid = Convert.ToInt32(ds.Tables[0].Rows[0][19]);
byte strType;
if (RadioButton1.Checked)
...{
strType = 2;
}
else
...{
strType = 1;
}
string strExplain = this.TextBox2.Text;
/**//////////////////////////图片byte//////////////////////
Stream file;
string picType;
int iLenght;
byte[] fileByte;
if (FUupdate.PostedFile.FileName != "")
...{
picType = FUupdate.PostedFile.ContentType;
string fillname = FUupdate.PostedFile.FileName;
string filetype = fillname.Substring(fillname.LastIndexOf(".") + 1);
if (filetype == "gif" || filetype == "jpg")
...{
file = FUupdate.PostedFile.InputStream;
iLenght = FUupdate.PostedFile.ContentLength;
fileByte = new byte[iLenght];
file.Read(fileByte, 0, iLenght);
if (Service.AddService(id, iOperatorid, picType, fileByte, strType, strExplain))
...{
this.Panel1.Visible = false;
this.Panel3.Visible = true;
}
else
...{
this.Panel1.Visible = false;
this.Panel2.Visible = true;
}
}
else
...{
this.Label5.Text = "文件格式不对!";
}
}
else
...{
picType = null;
fileByte = null;
if (Service.AddService(id, iOperatorid, strType, strExplain))
...{
this.Panel1.Visible = false;
this.Panel3.Visible = true;
}
else
...{
this.Panel1.Visible = false;
this.Panel2.Visible = true;
}
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class addtask : System.Web.UI.Page
...{
static int id;
protected void Page_Load(object sender, EventArgs e)
...{
if (Session["id"] == null)
...{
Response.Redirect("Default.aspx");
}
else
...{
if (Session["IsMain"].ToString() == "1")
...{
}
else
...{
if (Session["IsMain"].ToString() == "2")
...{
}
else
...{
Response.Redirect("Default.aspx");
}
}
}
if (!this.IsPostBack)
...{
id = Convert.ToInt32(Request.QueryString["id"]);
DataSet ds = Custmer.SelCustmer(id);
this.Label15.Text = ds.Tables[0].Rows[0][1].ToString();
this.Label16.Text = ds.Tables[0].Rows[0][2].ToString();
ds.Clear();
this.Panel1.Visible = true;
this.Panel2.Visible = false;
this.Panel3.Visible = false;
this.Badd.Attributes["onclick"] = "javascript:jump();";
}
}
protected void Badd_Click(object sender, EventArgs e)
...{
DataSet ds = Custmer.SelCustmer(id);
int iOperatorid = Convert.ToInt32(ds.Tables[0].Rows[0][19]);
byte strType;
if (RadioButton1.Checked)
...{
strType = 2;
}
else
...{
strType = 1;
}
string strExplain = this.TextBox2.Text;
/**//////////////////////////图片byte//////////////////////
Stream file;
string picType;
int iLenght;
byte[] fileByte;
if (FUupdate.PostedFile.FileName != "")
...{
picType = FUupdate.PostedFile.ContentType;
string fillname = FUupdate.PostedFile.FileName;
string filetype = fillname.Substring(fillname.LastIndexOf(".") + 1);
if (filetype == "gif" || filetype == "jpg")
...{
file = FUupdate.PostedFile.InputStream;
iLenght = FUupdate.PostedFile.ContentLength;
fileByte = new byte[iLenght];
file.Read(fileByte, 0, iLenght);
if (Service.AddService(id, iOperatorid, picType, fileByte, strType, strExplain))
...{
this.Panel1.Visible = false;
this.Panel3.Visible = true;
}
else
...{
this.Panel1.Visible = false;
this.Panel2.Visible = true;
}
}
else
...{
this.Label5.Text = "文件格式不对!";
}
}
else
...{
picType = null;
fileByte = null;
if (Service.AddService(id, iOperatorid, strType, strExplain))
...{
this.Panel1.Visible = false;
this.Panel3.Visible = true;
}
else
...{
this.Panel1.Visible = false;
this.Panel2.Visible = true;
}
}
}
}
- 上传图片至数据库
- 图片上传至数据库
- asp图片上传至数据库代码
- 上传图片到数据库
- 上传图片到数据库
- 图片上传到数据库
- 上传图片到数据库
- 图片上传到数据库
- 图片上传到数据库
- ASP.NET 上传图片至数据库并读取图片显示
- ASP.NET上传图片至数据库并显示图片
- ASP.NET 上传图片至数据库并读取图片显示
- 上传图片(图片相对路径)至数据库,并显示
- 单个图片上传到数据库
- 把图片上传到数据库
- 图片上传数据库的总结
- 图片上传数据库的总结
- 上传图片到数据库中。。。
- 关于XPath
- 程序生成文件下载
- 十二月的第一天,想到了人生
- 代码大全中提到的软件隐喻
- Jbuilder,NetBeans,Eclipse的输出Bug
- 上传图片至数据库
- mssql跨服务器查询的实现(转载)
- 关于防暴力破解的新思路
- 不定数量的CheckBox如何判断用户是否选中
- WEB应用中的身份验证(1)--基本身份验证BASIC authorization method
- C++成长经历
- .NET中各种数据库连接大全
- 从数据库读取图片
- Windows下DLL编程技术及应用