Wednesday, September 11, 2013

[php]upload file with cross domain

this is the only way I can find to post data with cross domain
switch ($_SERVER['HTTP_ORIGIN']) {
    case 'http://pro.sppp.com': case 'https://pro.sppp.com':
    header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']);
    header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
    header('Access-Control-Max-Age: 1000');
    header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
    break;
}

No comments: