CORS在Fine Uploader中不起作用

时间:2013-05-08 07:01:30

标签: php javascript cors

我的代码可以返回null,用户两个域, 客户端代码(js)www.a.com

<script type="text/javascript">
    $(function(){
        $('#uploadbtn').fineUploader({
            request: {
                endpoint: 'http://www.b.com/upload/binary'
            },
            cors: {
                expected: true, 
                sendCredentials: false 
            }
        });
    });
</script>

和服务器端(php)(www.b.com)

header("Access-Control-Allow-Origin:*");
    $uploader = new qqFileUploader();
    $uploader->allowedExtensions = array();
    $uploader->sizeLimit = 8 * 1024 * 1024;
    $uploader->inputName = 'qqfile';
    $uploader->chunksFolder = 'chunks';
    $result = $uploader->handleUpload('userdata');

    if (@$result['error']){
        $result['success'] = false;
    }else{
        $result['fileName'] = $uploader->getUploadName();
        $result['fileType'] = $uploader->getFileType();
        $result['fileDir'] = $uploader->getFileDir();
        $mediaId = $this->save($result['fileType'], $result['fileName'], $result['fileDir']);
        $result['id'] = $mediaId;
    }

    header("Content-Type: text/plain");
    echo json_encode($result);

我需要一个可以正常操作的演示。谢谢~~

0 个答案:

没有答案