问题
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
回答1:
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.
回答2:
It is due to cache most of the time.. try to change your Javascript include as below and error will be gone!.
<script type="text/javascript" src="<<path-to-uploadify>>/jquery.uploadify-3.1.js?ver=<?php echo rand(0,999999);?>"></script>
回答3:
If this is your current code - shouldn't the 'basePath' be a relative/direct url ?
So, instead of
var basePath = "path to ressources";
Shouldn't it be more like
var basePath = "/assets/RESOURCE_FOLDERNAME";
or an empty string ?
来源:https://stackoverflow.com/questions/24951141/uploadify-in-chrome-return-aw-snap-page