如何HTTP将Blob发布到不同的域? [英] How to HTTP POST a Blob to a different domain?

查看:447
本文介绍了如何HTTP将Blob发布到不同的域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 Blob()对象。我想上传到其他地方(通过表单处理用户上传的网站)。



我可以将它们放在 FormData 中并发送一个 XMLHttpRequest 对象,但后来我无法读取ajax响应,因为我被 ajax调用的相同来源政策



我该如何解决这个问题?有没有一些方法可以在不使用ajax的情况下进行常规上传?有没有一种方法可以处理那些适用于最新版本的Chrome和Firefox的同源策略?



编辑:不确定这是否是重复的:我无法控制发布的服务器,因此只要在两个域中设置相同的来源策略即可。


<在大多数情况下,当有人试图跨域使用AJAX但被相同的源策略阻止时,建议将AJAX添加到您自己的PHP页面,然后使用cURL将该数据发送到其他网站。



http: //curl.haxx.se/


I have some Blob() object. I want to upload somewhere else (a website that handle user upload through forms).

I can put them in a FormData and send them through an XMLHttpRequest object, but then I can't read the ajax response, because I'm blocked by the same origin policy of the ajax call.

How can I get around this? Is there some way to do a regular upload without using ajax? Is there a way to deal with that "same origin policy" that will work on recent versions of Chrome and Firefox?

edit: Not sure this is a duplicate: I don't control the server being posted, so I'm not OK with just "setting the same origin policy on both domains".

解决方案

In most cases when someone is trying to use AJAX across domains but is blocked by the same origin policy, it is recommended to AJAX to your own PHP page, and then use cURL to send that data to a different site.

http://curl.haxx.se/

这篇关于如何HTTP将Blob发布到不同的域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆