How to HTTP POST a Blob to a different domain? [duplicate]

孤者浪人 提交于 2019-12-08 05:40:38

问题


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".


回答1:


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/



来源:https://stackoverflow.com/questions/17977064/how-to-http-post-a-blob-to-a-different-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!