SWFUpload适用于IE,但不适用于Firefox

时间:2010-02-10 00:44:07

标签: firefox swfupload asyncfileupload file-upload

使用SWFUpload v2.2,Firefox 3,IE 8,Flash 10 在我的ASP.NET应用程序中,upload.aspx正在处理所有上传(我在设置对象中设置了正确的upload_url)。在IE 8中,上传到upload.aspx页面并进行处理,但在Firefox中却没有。有什么建议?

此处显示了用户访问以上传文件的页面的大部分代码(注意:正在使用母版页):

<script type="text/javascript" src="../swfupload/swfupload.js"></script>

<script type="text/javascript" src="../js/handlers.js"></script>

<script type="text/javascript">
    var swfu;
    window.onload = function() {
        swfu = new SWFUpload({
            // Backend Settings
            upload_url: "../upload.aspx",
            post_params: {
                "ASPSESSID": "<%=Session.SessionID %>"
            },

            // File Upload Settings
            file_size_limit: "10 MB",
            file_types: "*.*",
            file_types_description: "All Files",
            file_upload_limit: 1,
            file_queue_limit: 1,
            //assume_success_timeout: 60,

            // Event Handler Settings - these functions as defined in Handlers.js
            //  The handlers are not part of SWFUpload but are part of my website and control how
            //  my website reacts to the SWFUpload events.
            file_queue_error_handler: fileQueueError,
            file_dialog_complete_handler: fileDialogComplete,
            upload_progress_handler: uploadProgress,
            upload_error_handler: uploadError,
            upload_success_handler: uploadSuccess,
            upload_complete_handler: uploadComplete,

            // Button settings
            button_image_url: "../Images/XPButtonNoText_160x22.png",
            button_placeholder_id: "spanButtonPlaceholder",
            button_width: 160,
            button_height: 22,
            button_text: '<span class="button">Upload File<span class="buttonSmall">(10 MB Max)</span></span>',
            button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
            button_text_top_padding: 1,
            button_text_left_padding: 5,

            // Flash Settings
            flash_url: "../swfupload/swfupload.swf", // Relative to this file

            custom_settings: {
                upload_target: "divFileProgressContainer"
            },

            // Debug Settings
            debug: false
        });
    }
</script>

6 个答案:

答案 0 :(得分:2)

我知道,它是一个旧帖子,但也许它会帮助解决某些人的问题,因为我今天遇到了同样的问题。

我解决了这个问题,而不是使用post数组,因为我不知道如何以及在何处调试此脚本,但是生成查询字符串

<script type="text/javascript">
    var swfu;
    window.onload = function() {
        swfu = new SWFUpload({
            // Backend Settings
            upload_url: "../upload.aspx",
            post_params: {
                SessionID: "<%=Session.SessionID %>",
                OtherID: "<%=OtherID %>"
            },

            //And here comes the highlight

            use_query_string : true,

            //code ...

在此之后,您将获得如下的查询字符串:?SessionID=(id)&OtherID=(otherid)

这适用于每个浏览器下的保证。

答案 1 :(得分:2)

尝试使用其他浏览器,例如Safari或Chrome。

如果它仅适用于IE,则可能是其他答案中提到的F​​lash Cookie Bug。

如果它适用于除Firefox之外的所有内容,则可能是没有为进度条定义css。我不知道为什么这会导致问题,但我发现它确实存在问题。一旦我将样本样式放入我的css文件中,它就开始在Firefox中运行。

我使用的CSS如下:

DIV.ProgressBar { width: 100px; padding: 0; border: 1px solid black; margin-right: 1em; height:.75em; margin-left:1em; display:-moz-inline-stack; display:inline-block; zoom:1; *display:inline; }
DIV.ProgressBar DIV { background-color: Green; font-size: 1pt; height:100%; float:left; }
SPAN.asyncUploader OBJECT { position: relative; top: 5px; left: 10px; }

答案 2 :(得分:1)

使用HTTP跟踪/调试代理来查看是否有任何实际发送到服务器的内容以及正在接收的响应(如果有)。查尔斯是我的最爱,并且使用Flash(以及其他所有HTTP)都很棒。 WireShark和Fiddler是其他选择。

查尔斯 http://www.xk72.com/charles/

是Wireshark http://www.wireshark.org/

的Fiddler http://www.fiddler2.com/fiddler2/

答案 3 :(得分:1)

http://demo.swfupload.org/Documentation/

Cookie问题

在Windows上,非IE Flash Player插件(FireFox,Opera,Safari等)将发送IE cookie,无论使用何种浏览器。这破坏了许多服务器端脚本技术的身份验证和会话。

开发人员应手动传递会话和身份验证Cookie信息,并在他们希望使用会话时手动恢复服务器端的会话

SWFUpload包中包含PHP和ASP.Net的解决方法示例代码

=====从那里实施一些一次性认证票将使事情正常

您还可以指定仅在用户使用上传时应用此身份验证

但是,根据您为此操作发布cookie的方式,确保身份验证cookie无法绕过网站其他部分的某些测试可能很重要。

答案 4 :(得分:1)

只是想确认通过将post_params变量添加到SWFUpload init来解决同样的问题。

post_params : {
    PHPSESSID : '<?=session_id()?>'
},

答案 5 :(得分:0)

听起来你可能会遇到this Flash bug。 Nort的解决方案是大多数人一直在努力的方式。但是,根据您的语言/框架,您可能需要添加一些额外的服务器端代码以从URL中获取会话变量并强制将其用作当前会话。

您可以在this StackOverflow question中尝试解决方案,或尝试使用Google搜索“flash upload cookie”之类的内容。