我正在试用IE9上的plupload,它与Flash安装完美配合... 但没有它,浏览按钮什么都不做......我在控制台中没有发现任何错误。 请建议如何处理此异常,以便我可以通知用户安装Flashplayer
谢谢!
答案 0 :(得分:1)
这是plupload示例的修改版本,它应该做你想要的。主要兴趣点位于代码底部的错误处理程序中。
var uploader = new plupload.Uploader({
runtimes : 'html5,flash',
browse_button : 'pickfiles', // you can pass in id...
container: document.getElementById('container'), // ... or DOM Element itself
url : 'upload.php',
flash_swf_url : '../js/Moxie.swf',
silverlight_xap_url : '../js/Moxie.xap',
filters : {
max_file_size : '10mb',
mime_types: [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
]
},
init: {
PostInit: function() {
document.getElementById('filelist').innerHTML = '';
document.getElementById('uploadfiles').onclick = function() {
uploader.start();
return false;
};
},
FilesAdded: function(up, files) {
plupload.each(files, function(file) {
document.getElementById('filelist').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
});
},
UploadProgress: function(up, file) {
document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
},
Error: function(up, err) {
if(err.code === plupload.INIT_ERROR)
{
alert('Please install or activate flash player');
}
document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
}
}
});
uploader.init();