zoukankan      html  css  js  c++  java
  • 上传图片

    //随手拍图片
                    string url = "http://localhost:8099/OpenAPI/UpLoadPhotographImage";
                    string imgresult = "";
                    List<string> imglist = new List<string>();
                    foreach (imglist item in img)
                    {
                        string img1 = item.imgurl;
                        if (img1 != null && img1.Length > 0)
                        {
                            WebRequest request = System.Net.WebRequest.Create(url);

                            request.Method = "POST";
                            request.ContentType = "application/x-www-form-urlencoded";

                            Stream reqStream = request.GetRequestStream();
                            string img1base64 = System.Web.HttpUtility.UrlEncode(img1);
                            Encoding encoding = Encoding.GetEncoding("utf-8");
                            byte[] postdata = encoding.GetBytes("img1base64=" + img1base64);
                            reqStream.Write(postdata, 0, postdata.Length);
                            reqStream.Close();

                            HttpWebResponse myResponse = (HttpWebResponse) request.GetResponse();
                            StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("gb2312"));
                            imgresult = reader.ReadToEnd();//得到结果
                            imglist.Add(imgresult);
                        }
                    }
                    Service_Photoes pEntity = new Service_Photoes();
                    if (imglist.Count > 0)
                    {
                        pEntity.ServiceOrderId = OrderCode;
                        pEntity.ImageUrl = imglist[0];
                        pEntity.FileName = "服务";
                        pEntity.ThumbnailUrl100 = imglist[0];
                        pEntity.ThumbnailUrl160 = imglist[0];
                        pEntity.ThumbnailUrl180 = imglist[0];
                        pEntity.ThumbnailUrl220 = imglist[0];
                        pEntity.ThumbnailUrl310 = imglist[0];
                        pEntity.ThumbnailUrl40 = imglist[0];
                        pEntity.ThumbnailUrl410 = imglist[0];
                        pEntity.ThumbnailUrl60 = imglist[0];
                        //pEntity.ImageUrl2 = imglist.Count > 1 ? imglist[1] : "";
                        //pEntity.ImageUrl3 = imglist.Count > 2 ? imglist[2] : "";
                        //pEntity.ImageUrl4 = imglist.Count > 3 ? imglist[3] : "";
                        //pEntity.ImageUrl5 = imglist.Count > 4 ? imglist[4] : "";
                    }

                    Service_OrderBll orderBll = new Service_OrderBll();
                    Service_PhotoesBll photoesBll = new Service_PhotoesBll();
                    bool bRet = orderBll.SubmitService(entity);
                    if (pEntity.ImageUrl != "")
                    {
                        photoesBll.SubmitPhotograph(pEntity);
                    }

  • 相关阅读:
    大厂面试高频Redis,记不住的多操作几次吧
    自动化测试系列之jenkins配置搭建环境
    关于linux服务器的磁盘监控的相关知识
    前端常见一些安全问题及解决方案
    如何使用PM2部署前端项目
    vuex状态管理器本地持久化
    关于在Vue中Typescript的写法
    websocket快速重连机制
    如何使用selenium打开多个浏览器
    运维人员踩坑记录之netplan遇坑,配置临时IP巧妙解决
  • 原文地址:https://www.cnblogs.com/lsLNN/p/12056289.html
Copyright © 2011-2022 走看看