分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

kindedit,uedit 上传跨域返回

发布时间:2023-09-06 02:03责任编辑:董明明关键词:跨域

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

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved