Cross-Origin Request Headers(CORS) with PHP headers

后端 未结 11 1351
情书的邮戳
情书的邮戳 2020-11-21 11:13

I have a simple PHP script that I am attempting a cross-domain CORS request:



        
11条回答
  •  日久生厌
    2020-11-21 11:46

    I've simply managed to get dropzone and other plugin to work with this fix (angularjs + php backend)

     header('Access-Control-Allow-Origin: *'); 
        header("Access-Control-Allow-Credentials: true");
        header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
        header('Access-Control-Max-Age: 1000');
        header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization');
    

    add this in your upload.php or where you would send your request (for example if you have upload.html and you need to attach the files to upload.php, then copy and paste these 4 lines). Also if you're using CORS plugins/addons in chrome/mozilla be sure to toggle them more than one time,in order for CORS to be enabled

提交回复
热议问题