我在$(function() { ... });
正文中有简单的javascript函数
var uploader = new plupload.Uploader({
runtimes: 'html5,flash,silverlight',
browse_button: 'pickfiles',
container: 'uploader',
max_file_size: '20mb',
unique_names: true,
multiple_queues: false,
//drop_element: 'dropzone',
url: '/Home/Upload',
flash_swf_url: '../../../Scripts/upload/plupload.flash.swf',
silverlight_xap_url: '../../../Scripts/upload/plupload.silverlight.xap',
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
],
chunk_size: '2mb',
resize: { width: 320, height: 240, quality: 90 }
});
uploader.bind("Init", function (up, params) {
$("#runtime").html("<div>Current runtime: " + params.runtime + "</div>");
});
$("#uploadfiles").bind("click", function (e) {
uploader.start();
e.preventDefault();
});
uploader.init();
uploader.bind("FilesAdded", function (up, files) {
$.each(files, function (i, file) {
$('#runtime').append(
'<div id="' + file.id + '">' +
file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
'</div>');
});
up.refresh();
});
uploader.bind("UploaderProgress", function (up, file) {
$("#" + file.id + " b").html(file.percent + "%");
});
uploader.bind("Error", function (up, file) {
$('#runtime').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>");
up.refresh();
});
uploader.bind("FileUploaded", function (up, file) {
$("#" + file.id + " b").html("100%");
});
和 HTML 代码
<div class="container">
<div>Logo: </div>
<div style="clear"></div>
<div id="uploader">
<div id="runtime" class="right">
No runtime was found !
</div>
<div>
<a id="pickfiles" href="#">[Select files]</a>
<a id="uploadfiles" href="#">[Upload files]</a>
</div>
</div>
</div>
错误如下图所示:
http://i.imgur.com/5t0sT.jpg(查看全尺寸)
我看到文件过滤器有问题。我在 IE8 上运行 PLUpload.com 示例,它在 Flash 运行时运行良好。
在其他浏览器上,我的上传器运行良好。此外,我已经为所有浏览器(IE8、FF9、Chrome 16)安装了最新版本的 Flash,但问题仍然存在于 IE8 中。
问题已修复:请勿将上传器对象插入具有visibility:hidden
或display:none
属性的 div。