在 Chrome 中上传返回 Aw, Snap 页面

2021-12-20 00:00:00 php flash uploadify

从 chrome 的上次更新(版本 36.0.1985.125 m)开始,我遇到了 uplodify 插件/flash 的问题.Chrome 会显示 Aw、Snap Page 或有时他死了,Jim!.这是我的上传代码:

from last update of chrome (Version 36.0.1985.125 m) i have problem with uplodify plugin/flash. Chrome shows Aw, Snap Page or sometimes He's Dead, Jim!. Here is my uplodify code:

<input type="file" name="file_upload" id="file_upload_50">
<script type="text/javascript">
var basePath = "path to ressources";
var errorMessage = "Error Message";
var allowExts = "*.pdf; *.xls; *.xlsx; *.rar; *.zip";
$(document).ready(function() {
    var is_error = false;
    $('#file_upload_50').uploadify({
        'swf': basePath + '/uploadify/uploadify.swf',
        'uploader': "uploader.php",
        'height': 25,
        'buttonText': "Upload",
        'fileTypeExts': allowExts,
        'fileTypeDesc': "Formats:" + allowExts,
        'formData': {
            'user_id': 50,
            'company_id': 1
        },
        'onUploadError': function(file, errorCode, errorMsg, errorString) {
            alert(errorMessage);
            is_error = true;
        },
        'onUploadSuccess': function(file, data, response) {
            var result = $.parseJSON(data);
            if (!result.result) {
                alert(result.error_msg);
                is_error = true;
            }
        },
        'onQueueComplete': function(queueData) {
            if (!is_error) {
                document.location.href = "result_page.html";
            }
        }
    });
});
</script>

问题出在哪里?你能给我一些建议吗.我很无奈.谢谢

Where is the problem? Can you get me some advice. I am helpless. Thanks

推荐答案

我发现添加 setTimeout 可以解决这个问题.这表明 Chrome/Chrome 的 Flash 实现/Uploadify 的 Flash 应用程序中存在竞争条件,具体情况尚不清楚.尽管如此,它似乎适用于我们用例的所有情况.

I've found that adding a setTimeout fixes this. This would indicate a race condition in Chrome / Chrome's Flash implementation / Uploadify's Flash app, the circumstances of which are not clear. Nonetheless, it appears to work in all situations for our use case.

$(document).ready(function () {
    setTimeout(function () {
        $('foo').uploadify({...});
    }, 0);
});

这不是一个好的答案,但在没有解决方案的情况下,这是一个可用的解决方法.

This isn't a good answer, but in the absence of a solution, it's a usable workaround.

相关文章