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

     

  • 相关阅读:
    服务端跳转和客户端跳转的区别
    jsp:include标签与include指令的区别
    jsp错误页不跳转显示500
    使用Cookie进行会话管理
    深入理解重定向和转发
    appium环境搭建(二)----搭建android开发环境
    appium环境搭建(一)----安装appium
    Fiddler实现移动端手机抓包
    黑盒测试人员必备技能
    SVN服务器搭建
  • 原文地址:https://www.cnblogs.com/elsons/p/9283030.html
Copyright © 2011-2022 走看看