FileUpload上传控件1
来源:互联网 发布:java web微信支付demo 编辑:程序博客网 时间:2024/05/20 00:12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = FileUpload1.FileName;//上传文件名字
string size = FileUpload1.PostedFile.ContentLength.ToString();
string type = FileUpload1.PostedFile.ContentType;
string type2 = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("upimg") + "//" + name;
string fpath = Server.MapPath("upfile") + "//" + name;
string path="F://aaa//"+FileUpload1.FileName;
string wpath = "upimg//" + name;
if (type2 == "jpg" || type2 == "gif" || type2 == "bmp" || type2 == "png")
{
FileUpload1.SaveAs("F://aaa//"+FileUpload1.FileName);
// Image1.ImageUrl="F://aaa//"+FileUpload1.FileName;
Label1.Text = "你传图片的名字是" + name + "<br>文件大小为" + size + "<br>文件类型为" + type2 + "<br>文件路径为" + ipath;
}
SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("insert into Image(imageName,imagepath) values('" + name + "','" + path + "')", cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{ SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("select imageName from Image where imageID='" + Convert.ToInt32(TextBox1.Text) + "'", cn);
cn.Open();
string a = cmd.ExecuteScalar().ToString();
cn.Close();
Image1.ImageUrl = "F://aaa//" + a;
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = FileUpload1.FileName;//上传文件名字
string size = FileUpload1.PostedFile.ContentLength.ToString();
string type = FileUpload1.PostedFile.ContentType;
string type2 = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("upimg") + "//" + name;
string fpath = Server.MapPath("upfile") + "//" + name;
string path="F://aaa//"+FileUpload1.FileName;
string wpath = "upimg//" + name;
if (type2 == "jpg" || type2 == "gif" || type2 == "bmp" || type2 == "png")
{
FileUpload1.SaveAs("F://aaa//"+FileUpload1.FileName);
// Image1.ImageUrl="F://aaa//"+FileUpload1.FileName;
Label1.Text = "你传图片的名字是" + name + "<br>文件大小为" + size + "<br>文件类型为" + type2 + "<br>文件路径为" + ipath;
}
SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("insert into Image(imageName,imagepath) values('" + name + "','" + path + "')", cn);
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{ SqlConnection cn = new SqlConnection("server=.;database=Northwind;uid=sa;pwd=sa");
SqlCommand cmd = new SqlCommand("select imageName from Image where imageID='" + Convert.ToInt32(TextBox1.Text) + "'", cn);
cn.Open();
string a = cmd.ExecuteScalar().ToString();
cn.Close();
Image1.ImageUrl = "F://aaa//" + a;
}
}
- FileUpload上传控件1
- 上传控件---FileUpload
- 文件上传控件(FileUpload)
- FileUpload 上传控件
- FileUpload控件上传图片
- FileUpload控件上传文件
- FileUpload文件上传控件
- FileUpload控件上传大文件
- .net fileupload上传控件【原创】
- FileUpload控件实现上传文件
- Richfaces rich:fileUpload 上传控件
- FileUpload上传控件用法详解
- 用FileUpload控件上传文件
- .net C# FileUpload控件上传
- 使用FileUpload上传控件上传文件
- ASP:FileUpload控件(文件上传控件)
- ASP.NET基本控件FileUpload上传控件
- fileupload控件上传图片生成缩略图
- datalist删除多行记录
- 全屏窗口javascript
- datalist用法整合
- datareader读数据存列表中
- vs2008与vs2005的冲突
- FileUpload上传控件1
- Gridview鼠标选定颜色和具体列颜色
- FRAMESET 元素 | frameSet 对象
- Gridview自定义分页
- win2000/xp/2003下完全卸载ORACLE
- C# 开机启动
- image控件写成流的形式存SQL
- MyEclipse_6.0.1GA_E3.3常用简介
- JSP 实现文件上传