图片文件上传

C# code
/// <summary> /// 上传图片 /// </summary> /// <param name="caseid">案件号</param> /// <param name="twoid">车编号、人编号</param> /// <param name="pic">压缩后二进制格式的图片</param> /// <param name="picmemo">图片备注</param> /// <param name="tablename">存储在数据库中的表名</param> /// <param name="filedname">单证类型</param> /// <param name="exifTime">EXIF信息</param> /// <returns></returns> public string CaseUpLoadImage(string caseid, int twoid, byte[] pic, string picmemo, string tablename, string filedname, string exifTime) { try { MyFrame.Base.CompressionHelper ch = new CompressionHelper(); byte[] images = ch.DecompressToBytes(pic); //解压 MemoryStream ms = new MemoryStream(images); Bitmap img = new Bitmap(ms); string picTmpFilesPath = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString(); string picTmpFiles = picTmpFilesPath + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + ".jpg"; picTmpFilesPath = Server.MapPath("~/uploadfiles/" + picTmpFilesPath); if (!Directory.Exists(picTmpFilesPath)) { Directory.CreateDirectory(picTmpFilesPath); } picTmpFilesPath = picTmpFilesPath + @"\" + picTmpFiles; img.Save(picTmpFilesPath); DataOperation mydo = new DataOperation(); string strsql = ""; if (filedname != "") { strsql = "Insert into " + tablename + "(TWOID,CASEID,PICPATH,NOTE,ADDDATE,DZCLASS,EXIFTIME)" + " values (" + twoid + ",'" + caseid + "','" + picTmpFilesPath + "','" + picmemo + "',to_date('" + DateTime.Now.ToString() + "','yyyy-mm-dd hh24-mi-ss'),'" + filedname + "','" + exifTime + "')"; } else { strsql = "Insert into " + tablename + "(TWOID,CASEID,PICPATH,NOTE,ADDDATE,EXIFTIME)" + " values (" + twoid + ",'" + caseid + "','" + picTmpFilesPath + "','" + picmemo + "',to_date('" + DateTime.Now.ToString() + "','yyyy-mm-dd hh24-mi-ss'),'" + exifTime + "')"; } if (!mydo.SetExeSql(strsql)) { return mydo.ErrInfo; } return "1"; } catch (Exception ex) { return ex.Message; } } private void c_OnShangChuan(object sender, EventArgs e) { UpLoadPic[] abc = uploadimages1.FileNames; uploadimages1.ProgressBarMax = abc.Length; string a = ""; string b = ""; for (int i = 0; i < abc.Length; i++) { a = abc[i].path; b = abc[i].exifTime; Bitmap bmp = new Bitmap(a); string aa = sc.CaseUpLoadImage(caseid, TwoId, ImageGdi(bmp), "", imagePath, DzClass,b); if (aa != "1") { uploadimages1.AddSangChuanInfo(aa); } else { uploadimages1.ProgressBarStep(i+1); uploadimages1.AddSangChuanInfo(string.Format("上传{0}图片成功!",abc[i].path)); } Application.DoEvents(); } uploadimages1.AddSangChuanInfo("----------------------------"); uploadimages1.AddSangChuanInfo("所有图片上传完毕!"); uploadimages1.UpLoadOver(); Application.DoEvents(); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值