当前位置: 首页 > news >正文

网站上传照片失败建站之星网站空间根目录

网站上传照片失败,建站之星网站空间根目录,辽宁城乡建设部网站,网站建设亇金手指排名十五在SQL SERVER中建立这样结构的一个表#xff1a;列名类型目的IDInteger主键IDIMGTITLEVarchar(50)图片的标题IMGTYPEVarchar(50)图片类型. ASP.NET要以辨认的类型IMGDATAImage用于存储二进制数据 using System;using System.Collections;using System.Configuration;using…在SQL SERVER中建立这样结构的一个表列名类型目的IDInteger主键IDIMGTITLEVarchar(50)图片的标题IMGTYPEVarchar(50)图片类型. ASP.NET要以辨认的类型IMGDATAImage用于存储二进制数据       using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.Drawing;using System.Drawing.Imaging;using System.Drawing.Drawing2D;using System.Data.SqlClient;using System.IO; public partial class ChangeImageSize : System.Web.UI.Page{    protected void Page_Load(object sender, EventArgs e)    {     }         private int width;        private int height;        private Bitmap newpic, savepic;        private float k1, k2;         /// summary        /// 构造函数        /// /summary        public ChangeImageSize()        {        }                       /// summary        /// 传入一张图片并设定它的大小        /// /summary        /// param nameTheImage传入的图片对象/param        /// param nameTheWidth图片宽的范围/param        /// param nameTheHeight图片长的范围/param        /// param namepath保存的文件名和路径/param        public Bitmap ChangePicMethod(object TheImage, int TheWidth, int TheHeight)        {            newpic new Bitmap((System.Drawing.Image)TheImage);            this.width newpic.Width;            this.height newpic.Height;             k1 (float)width / (float)TheWidth;            k2 (float)height / (float)TheHeight;            if (k1 k2)            {                this.width (int)(width / k1);                this.height (int)(height / k1);            }            else            {                this.width (int)(width / k2);                this.height (int)(height / k2);            }            savepic new Bitmap(newpic, width, height);            return savepic;            //savepic.Save(path);        }     /// summary    /// 保存图片到数据库    /// /summary    /// returns/returns        private bool StoreImage()        {            bool rs false;            Stream imgdatastream this.FileUpload1.PostedFile.InputStream;            int imgdatalen this.FileUpload1.PostedFile.ContentLength;            string imgtype this.FileUpload1.PostedFile.ContentType;            string imgtitle FileUpload1.PostedFile.FileName;            // byte[] imgdata new byte[imgdatalen];            //int n imgdatastream.Read(imgdata, 0, imgdatalen);            //Bitmap bp ChangePicToSaveMethod(imgdatastream, 200, 200);                       MemoryStream ms new MemoryStream();            Bitmap bp new Bitmap(imgdatastream);            bp ChangePicMethod(bp, 200, 200);            //bpbp.GetThumbnailImage(200,200,new System.Drawing.Image.GetThumbnailImageAbort(aa()) ,System.IntPtr.Zero);            bp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);            ms.Flush();            byte[] imgdata ms.GetBuffer();            ms.Close();               SqlConnection connection Connection.getConnection();            SqlCommand command new SqlCommand(INSERT INTO ImageStore(ImageTitle,ImageType,ImageData)VALUES ( imgtitle, imgtype,imgdata ), connection);             SqlParameter paramTitle new SqlParameter(imgtitle, SqlDbType.VarChar, 50);             paramTitle.Value imgtitle;            command.Parameters.Add(paramTitle);             SqlParameter paramData new SqlParameter(imgdata, SqlDbType.Image);            paramData.Value imgdata;            command.Parameters.Add(paramData);             SqlParameter paramType new SqlParameter(imgtype, SqlDbType.VarChar, 50);            paramType.Value imgtype;            command.Parameters.Add(paramType);             connection.Open();            int numRowsAffected command.ExecuteNonQuery();            connection.Close();            rs true;            return rs;        }    /// summary    /// 从数据库取出图片    /// /summary    /// param namesender/param    /// param namee/param        private void GetImage(string imgid)        {            string sql SELECT ImageData, ImageType FROM ImageStore WHERE ID imgid;            SqlConnection connection Connection.getConnection();            SqlCommand command new SqlCommand(sql, connection);            connection.Open();            SqlDataReader dr command.ExecuteReader();            if (dr.Read())            {                Response.ContentType dr[ImageType].ToString();                Response.BinaryWrite((byte[])dr[ImageData]);            }            connection.Close();         }   }转载于:https://www.cnblogs.com/carekee/articles/2083425.html
http://www.yutouwan.com/news/199288/

相关文章:

  • 做网站 做好把我踢开搭建网站的空间哪里买
  • 数据库网站建设方案服装设计以及网页设计素材
  • 三门峡做网站推广怎么做轴承网站
  • 安 网站建设网络营销学校
  • 洛阳网站建设培训什么叫做电商
  • 酒厂网站源码17网站一起做网店
  • 网站改版的原因wordpress 文本 点不了
  • 做国内学历公证的网站心理学网站可以在线做量表
  • 长沙旅游网站建设成都plc培训机构哪家最好
  • iis 5 新建网站山东最新资讯
  • 免费网站设计神器文章资讯类网站
  • 绍兴网站建设团队武昌做网站多少钱
  • 潮州外贸网站建设一站式网站建设与运营
  • 网站的内部链接如何做温州网站开发定制
  • 个人网站备案流程建设通官网登录入口
  • 做调查网站赚钱学校网站的页头图片做
  • 以小说名字做网站的小说网樟木头镇网站仿做
  • aspcms是网站什么漏洞苏州市吴江住房和城乡建设局网站
  • 房地产公司网站下载小县城做网站
  • 网站开发的认知优改网logo设计免费官网入口
  • h5自助建站系统wordpress 用户 购物
  • 代理加速器东莞做网站优化哪家好
  • 广州网站建设联享科技seo营销策略
  • 石狮住房和城乡建设网站模版网站有源代码吗
  • 专业做曝光引流网站金华市建设局官方网站
  • 论坛网站平台建设方案qq小程序怎么关闭
  • 网站建设开发 脚本语言网站建设项目培训
  • 启迪网站建设招聘wordpress搬家跳会首页
  • 中国服装设计网站小程序源码分享网
  • 扁平化设计网站 国内海口云建站模板