Flex上传安全性错误

时间:2011-11-14 20:09:45

标签: flex cross-domain

我有一个Flex应用程序可以将文件上传到我们的网站。 我们目前正致力于转移到新网站,目前必须通过IP而不是域名访问新网站。

上传应用程序在当前服务器上运行正常,但在新服务器上它会产生上传安全性错误。

我尝试将IP添加到crossdomain.xml,但是没有修复它。

我希望当我们将DNS切换到新服务器时,它才会开始工作,但是它立即正常工作非常重要。

[Event(name="uploadSecurityError", type="flash.events.SecurityErrorEvent")]
private var _refUploadFile:FileReference;

private function continueUpload():void {
    disableUI();
    if(AlertReturn){
        if (_arrUploadFiles.length > 0) {
            listFiles.selectedIndex = _numCurrentUpload;
            scrollFiles();
            // Variables to send along with upload
            var sendVars:URLVariables = new URLVariables();
            sendVars.dir = String(cboDir.selectedItem.data);
            sendVars.uname = String(cboUsername.selectedItem.data);
            sendVars.timekey = TimeKey;
            sendVars.proc = 0;

            var request:URLRequest = new URLRequest();
            request.data = sendVars;
            request.url = _strUploadUrl;
            request.method = URLRequestMethod.POST;
            _refUploadFile = new FileReference();
            _refUploadFile = listFiles.selectedItem.file;
            _refUploadFile.addEventListener(ProgressEvent.PROGRESS, onUploadProgress);
            _refUploadFile.addEventListener(Event.COMPLETE, onUploadComplete);
            _refUploadFile.addEventListener(IOErrorEvent.IO_ERROR, onUploadIoError);
            _refUploadFile.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onUploadSecurityError);
            _refUploadFile.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadDataComplete);
            _refUploadFile.upload(request, "file", false);
        }
    }
}

// Called on upload security error
private function onUploadSecurityError(event:SecurityErrorEvent):void {
    clearUpload();
    var evt:SecurityErrorEvent = new SecurityErrorEvent("uploadSecurityError", false, false, event.text);
    dispatchEvent(evt);
}

1 个答案:

答案 0 :(得分:2)

没关系。 我们更改了hosts文件以允许我们使用域名而不是ip,它运行得很好。

现在我必须弄清楚为什么它会删除此服务器上的文件名的第一个字母而不是旧的...