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(); ???????}
kindedit,uedit 上传跨域返回
原文地址:https://www.cnblogs.com/elsons/p/9283030.html