protected void Unnamed1_Click(object sender, EventArgs e)
{
string Sql = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
SqlConnection con = new SqlConnection(Sql);
con.Open();
//FileStream fs = File.Open(Server.MapPath( "img/"+ this.FileUpload1.PostedFile.FileName), FileMode.Open);
//byte[] by = new byte[fs.Length];
//fs.Read(by, 0, (int)fs.Length);
string SqlCmd = "insert into ImageStore(ImageData,ImageContentType,ImageDescription,ImageSize) values(@Image,@fileType,@fileDec,@fileSize)";
SqlCommand comobj = new SqlCo
以数据流的形式上传上传数据存入数据库
最新推荐文章于 2025-04-22 10:20:09 发布
这段代码展示了如何在ASP.NET中通过点击事件处理程序上传文件,并将其数据流插入到数据库的ImageStore表中。使用SqlConnection连接数据库,然后通过SqlCommand参数化查询将文件内容、类型、描述和大小保存到相应的字段。

最低0.47元/天 解锁文章
1168

被折叠的 条评论
为什么被折叠?



