zoukankan      html  css  js  c++  java
  • 将客户端图片保存到数据库

    1.将客户端图片保存到数据库

     protected void Button4_Click(object sender, EventArgs e)
            {
                HttpPostedFile upPhoto = f_1.PostedFile;
                int upPhotoLength = upPhoto.ContentLength;
                byte[] PhotoArray = new Byte[upPhotoLength];
                Stream PhotoStream = upPhoto.InputStream;
                PhotoStream.Read(PhotoArray, 0, upPhotoLength);///////////// 
    
                string constr = "Data Source=192.168.10.58; Initial Catalog=saveImagesDB; user ID=sa; password=123; pooling=true;";
                string strSQL = "insert into T_image(id,imageobj)values(@id,@imageobj)";
                SqlConnection con = new SqlConnection(constr);
                SqlCommand com3 = new SqlCommand(strSQL, con);
                Random ro = new Random();
                string id = ro.Next(1000).ToString();
                com3.Parameters.Add("@id", SqlDbType.VarChar).Value = id;
                com3.Parameters.Add("@imageobj", SqlDbType.Image).Value = PhotoArray;
                com3.Connection.Open();
                com3.ExecuteNonQuery();
            }
    
  • 相关阅读:
    Shiro权限验证
    5种设计模式整理
    多模块的SpringBoot项目
    Go使用数据库
    使用Go mod
    docker基本使用
    Go的IO操作
    实现一个网盘存储……
    Go的网络编程
    学习golang的历程
  • 原文地址:https://www.cnblogs.com/Evan-Pei/p/3314343.html
Copyright © 2011-2022 走看看