PHP header not working for Access-Control-Allow-Origin

前端 未结 3 684
不知归路
不知归路 2021-02-01 08:18

I am using the jQuery File Upload plugin by Blueimp to upload images to a server. The problem is, the sending server is admin.example.com, and the receiving server

相关标签:
3条回答
  • 2021-02-01 08:46

    The solution for me was to re-save the PHP file using UTF-8 encoding. Apparently the original text file (that I copied into place and overwrote for the quick test) used was using some other funky encoding.

    0 讨论(0)
  • 2021-02-01 09:00

    I use this headers and its work for me

    header('content-type: application/json; charset=utf-8');
    header("access-control-allow-origin: *");
    
    0 讨论(0)
  • 2021-02-01 09:01

    I would try to set this on the web.config since you're operating on an IIS server:

    https://gist.github.com/corydeppen/3518666

    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <!-- allowing all-->
                <add name="Access-Control-Allow-Origin" value="*" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
    
    0 讨论(0)
提交回复
热议问题