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);
                    }

  • 相关阅读:
    Linux磁盘系统——管理磁盘的命令
    Linux磁盘系统——磁盘系统简介
    LinuxShell——内嵌命令
    安装PHP出现make: *** [sapi/cli/php] Error 1 解决办法
    Linux常用命令
    Linux文件系统及文件类型
    MySQL查询语句
    Python随手记—各种方法的使用
    MySQL架构及SQL语句
    Python笔记记录
  • 原文地址:https://www.cnblogs.com/lsLNN/p/12056289.html
Copyright © 2011-2022 走看看