我正在尝试使用带有mvc2的plupload,但是文件浏览器窗口无法打开。
我的代码:
<script type="text/javascript">
// Convert divs to queue widgets when the DOM is ready
$(function () {
$("#uploader").pluploadQueue({
// General settings
runtimes: 'gears,flash,silverlight,browserplus,html5',
url: '<%: Url.Content( "~//Uploades/Horses/" ) %>',
max_file_size: '10mb',
chunk_size: '1mb',
unique_names: true,
// Resize images on clientside if we can
resize: { width: 320, height: 240, quality: 90 },
// Specify what files to browse for
filters: [
{ title: "Image files", extensions: "jpg,gif,png" },
{ title: "Zip files", extensions: "zip" }
],
// Flash settings
flash_swf_url: '../../../../Scripts/plupload/plupload.flash.swf',
// Silverlight settings
silverlight_xap_url: '../../../../Scripts/plupload/plupload.silverlight.xap'
});
// Client side form validation
$('form').submit(function (e) {
var uploader = $('#uploader').pluploadQueue();
uploader.refresh();
// Validate number of uploaded files
if (uploader.total.uploaded == 0) {
// Files in queue upload them first
if (uploader.files.length > 0) {
// When all files are uploaded submit form
uploader.bind('UploadProgress', function () {
if (uploader.total.uploaded == uploader.files.length)
$('form').submit();
});
uploader.start();
} else
alert('You must at least upload one file.');
e.preventDefault();
}
});
});
<div id="uploader" style="height:300px">
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
</div>
如果我尝试调试uploadingelemt显示没有任何问题。但是如果我点击添加文件,窗口就会跳到页面的顶部而不会发生其他情况。
Firebug没有出现任何问题。
我试过FF4&amp; IE 8使用flash和silverlight
任何一个想法? 非常感谢你,祝你周末愉快!
答案 0 :(得分:3)
您的浏览器将使用“html5”之前列出的Flash运行时。 Flash运行时需要设置'container:“my_uploader_container_id”'
你的'pickfiles'按钮需要放入ID为'my_uploader_container_id'的DIV。
另一个解决方案是使用html5引擎 - 在'runtimes'参数中将它列在flash之前。但是html5运行时在IE中不起作用。