zoukankan      html  css  js  c++  java
  • kindedit,uedit 上传跨域返回

    1.kindedit 跨域上传图片的时候,a.com 上传到b.com接收图片服务器,然后返回图片地址。

    2.一般如果不做任何处理是获取不到返回的信息的。原因是跨域了

    3.所以一般在上传成功后,在跳转回a.com的域名下。

    下面为b.com接收图片处理后返回数据

      public void UploadLoanWay()
            {
              
                PostResult result = new PostResult();
                try
                {
                    string time = DateTime.Now.ToString("yyyyMMdd");
                    string path = CreateMktFolder(time);
                    var fileInfo = CreateFile(path, null);
                    string filename = fileInfo.FileName + "." + fileInfo.Extension;
                    result.Status = 1;
                    result.FileName = time + "/" + filename;
                    System.Drawing.Image myImage = System.Drawing.Image.FromFile(Path.Combine(path, filename), true);
                    result.Width = myImage.Width;
                    result.Height = myImage.Height;
                }
                catch
                {
                    result.Status = 0;
                    result.Message = "上传文件失败";
                }
                //Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                //Response.Write(JsonMapper.ToJson(hash));
                //Response.End();
                Response.Redirect("http://cms.mkt.99asm.com/Result.ashx?result=" + result.FileName);
    
            }

    下面是a.com获取b.com 返回的信息 这样就能够获取到返回的信息了

      public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";
                Hashtable hash = new Hashtable();
                hash["error"] = 0;
                var result = context.Request["result"];
                //当然这里最好判断一下result是否安全,不要接收到内容就显示这样会被人利用。
                if (result != null)
                {
                    hash["url"] = "http://static.neihanhongbao.com/MktEdit/" + result;
                }
                context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                context.Response.Write(JsonMapper.ToJson(hash));
                context.Response.End();
            }

     

  • 相关阅读:
    数据库权限分配操作
    1130-host ... is not allowed to connect to this MySql server
    ubuntu 14.04安装mysql-python
    Ubuntu中的MySQL修改root密码的多种方法
    ubuntu下安装mysql及卸载mysql方法
    XShell本地上传文件到Ubuntu上及从Ubuntu下载文件到本地
    深度学习-1
    html-新闻滚动条
    Django部署uwsgi 与 nginx配置
    二叉树层次遍历
  • 原文地址:https://www.cnblogs.com/elsons/p/9283030.html
Copyright © 2011-2022 走看看