【问题标题】:Internet Explorer "Security error" uploadifyInternet Explorer“安全错误”上传
【发布时间】:2011-07-27 18:11:50
【问题描述】:

我正在使用uploadify 2.1.4,http://www.uploadify.com

本地js:

jQuery('#file_upload').uploadify({
   'buttonImg' : 'public/uploadify/newfile.png',
   'uploader' : 'http://remoteserver/uploadify.swf',
   'scriptAccess' : 'always', ...

在远程服务器我有这个跨域:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

我编辑uploadify.fla 并输入这段代码:

import flash.system.Security;
...
Security.allowDomain("*");

然后生成一个新的uploadify.swf

问题是: 使用 Firefox、Safari、Chrome e Opera,但在 IE(v7、v8、v9(我不使用 v6 测试))中仍然收到错误:安全错误(在 .uploadifyQueueItem 中)

【问题讨论】:

  • 我认为您对您要实现的目标感到非常困惑。为什么不先发布完整的错误代码,以便我们准确确定问题所在。

标签: jquery flash security uploadify


【解决方案1】:

当您可以直接从 Flash 上传到服务器时,我不确定为什么要使用 jquery 上传(因为无论如何您已经在使用 Flash)。我就是这样做的,我在 IE 中没有问题。抱歉,我无法直接回答您的问题,我对 JQuery 了解的不够多。

 var request:URLRequest = new URLRequest( "http://remoteserver/uploadify.swf" );
 request.data = myjpeg;
 request.contentType = "image/jpeg";
 request.method = URLRequestMethod.POST;
 var loader:URLLoader = new URLLoader(  );
 loader.addEventListener( Event.COMPLETE, handleResponse );
 loader.load( request );
 function handleResponse (evt:Event) { 
 trace(evt.target.data); //print response from server if there is one
 }

【讨论】:

    【解决方案2】:

    我解决了这个问题:

    在我的 js 中:

    jQuery('#file_upload').uploadify({
      script: '/upload',
      uploader: 'http://domain.com/uploadify.swf'
    

    但是,当在uploadify.swf 中打印(requestURL.url)时,会输入:“http://www.domain.com/upload”;所以 flash 会导致安全错误,因为 "http://www.dom..." != "http://dom..."

    【讨论】:

      【解决方案3】:

      我没有按照您在将文件从一台服务器上传到另一台服务器时修复 IE 安全问题的方法。

      我的 uploadify.swf 托管在服务器 1 上,上传 php 脚本在服务器 2 上。 服务器 2 上的 Crossdomain.xml 具有允许上传的指令。

      在 FF、Chrome、Safari 中运行良好,但 IE 会引发安全阻止程序。

      谢谢 梅尔温

      【讨论】:

        【解决方案4】:

        您好,我从另一个问题中得到了解决方案。 dynamically setting properties in uploadify

        添加以下属性以避免 IE8 中的安全异常

          'method' : 'GET',
        

        它现在对我有用。我的总代码如下所示

        $('#file_uploads').uploadify({
                'onUploadSuccess': function (file, data, response) {
                    $scope.uploadedFileList.push(JSON.parse(data)[0].files);
                    $scope.$apply();
                },
                'onQueueComplete': function (queueData) {
        
                },
                'onDialogClose': function (queueData) {
                    //            console.log(queueData);
                    if (queueData.filesSelected > 5 || (queueData.filesSelected + $scope.uploadedFileList.length) > 5) {
                        bootbox.alert({
                            title: CommonUtility.errorLabel,
                            message: "Maximum 5 files allowed.",
                            callback: function () {
        
                            }
                        });
                        $('#file_uploads').data('uploadify').queueData = "";
                    } else if (queueData.queueSize > 5000000) {
                        bootbox.alert({
                            title: CommonUtility.errorLabel,
                            message: "Total file size should not exceed 5 MB",
                            callback: function () {
        
                            }
                        });
                    } else
                        $('#file_uploads').uploadify('upload', '*');
                },
                'auto': false,
                'fileTypeExts': '*.gif; *.jpg; *.png; *.doc; *.pdf; *.xls; *.zip;',
                'scriptAccess': 'always',
                'swf': 'assets/css/uploadify.swf',
                'uploader': 'uploadfile',
                'method': 'GET',
                'buttonText': 'Browse',
            });
        

        【讨论】:

          猜你喜欢
          • 2020-05-29
          • 2018-07-11
          • 1970-01-01
          • 2013-05-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多