asp.net的image控件的使用
上传的代码stringname=FileUpload2.FileName;lianjdb=newlianj();stringtype=name.Substring(nam...
上传的代码
string name = FileUpload2.FileName;
lianj db = new lianj();
string type = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("..\\Imagess") + "\\" + name;
string wpath = "Imagess\\" + name;
string query1 = String.Format("insert into Images(Image_ID,Image_Wpath,miaoshu) values({0},'{1}','{2}')",Convert.ToInt16( TextBox1.Text),wpath,TextBox2.Text);
if (type == "jpg")
{
FileUpload1.SaveAs(ipath);
int i = db.ex(query1);
if (i == 0)
{
message.MessageBox(this, "上传失败");
}
else
{
message.MessageBox(this, "上传成功");
}
TextBox1.Text = "";
TextBox2.Text = "";
}
html里面传值zhanzhang.aspx?id=1
lianj db = new lianj();
string query2 = string.Format("select * from Images where Image_ID={0}", Convert.ToInt16(Request["id"]));
SqlDataReader sdr = db.ExecuteReader(query2);
string wpath2 = "";
while (sdr.Read())
{
wpath2 = sdr["Image_Wpath"].ToString();
Label1.Text = sdr["miaoshu"].ToString();
}
sdr.Close();
Image1.ImageUrl = wpath2;
Label2.Text = wpath2;
上传到数据库的路径多正确,但是image1读不出来
你没有看清楚啊 展开
string name = FileUpload2.FileName;
lianj db = new lianj();
string type = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("..\\Imagess") + "\\" + name;
string wpath = "Imagess\\" + name;
string query1 = String.Format("insert into Images(Image_ID,Image_Wpath,miaoshu) values({0},'{1}','{2}')",Convert.ToInt16( TextBox1.Text),wpath,TextBox2.Text);
if (type == "jpg")
{
FileUpload1.SaveAs(ipath);
int i = db.ex(query1);
if (i == 0)
{
message.MessageBox(this, "上传失败");
}
else
{
message.MessageBox(this, "上传成功");
}
TextBox1.Text = "";
TextBox2.Text = "";
}
html里面传值zhanzhang.aspx?id=1
lianj db = new lianj();
string query2 = string.Format("select * from Images where Image_ID={0}", Convert.ToInt16(Request["id"]));
SqlDataReader sdr = db.ExecuteReader(query2);
string wpath2 = "";
while (sdr.Read())
{
wpath2 = sdr["Image_Wpath"].ToString();
Label1.Text = sdr["miaoshu"].ToString();
}
sdr.Close();
Image1.ImageUrl = wpath2;
Label2.Text = wpath2;
上传到数据库的路径多正确,但是image1读不出来
你没有看清楚啊 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询