問題描述
從 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.
這篇關于在 Chrome 中上傳返回 Aw, Snap 頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!