C# ASP.Net/JQuery:PLUploader;添加文件";上传图像后不会触发
您好,我一直在使用asp.net c#的PLUploader控制器。它按预期工作(最初会出现),但一旦我上传了文件,控制器就会禁用“添加文件”按钮(或者按钮不工作),我无法添加更多图像 有人能帮忙吗?我已经张贴了下面的代码,我认为错误出现在,但如果任何其他代码是必要的,只要问一个我会编辑后 谢谢C# ASP.Net/JQuery:PLUploader;添加文件";上传图像后不会触发,c#,javascript,jquery,asp.net,C#,Javascript,Jquery,Asp.net,您好,我一直在使用asp.net c#的PLUploader控制器。它按预期工作(最初会出现),但一旦我上传了文件,控制器就会禁用“添加文件”按钮(或者按钮不工作),我无法添加更多图像 有人能帮忙吗?我已经张贴了下面的代码,我认为错误出现在,但如果任何其他代码是必要的,只要问一个我会编辑后 谢谢 <script type="text/javascript"> // Initialize the widget when the DOM
<script type="text/javascript">
// Initialize the widget when the DOM is ready
var initUploader = function () {
$("#uploader").plupload({
// General settings
runtimes: 'html5,flash,silverlight,html4',
url: '/Account/Upload.ashx',
// User can upload no more then 20 files in one go (sets multiple_queues to false)
//max_file_count: 10,
chunk_size: '1mb',
// Resize images on clientside if we can
resize: {
width: 800,
height: 600,
quality: 90,
crop: true // crop to exact dimensions
},
multiple_queues: true,
filters: {
// Maximum file size
max_file_size: '10mb',
// Specify what files to browse for
mime_types: [
{ title: "Image files", extensions: "jpg,gif,png,jpeg" },
{ title: "Zip files", extensions: "zip" }
]
},
// Resize images on clientside if we can
resize: { width: 800, height: 600, quality: 90 },
// Rename files by clicking on their titles
rename: true,
// Sort files
sortable: true,
// Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
dragdrop: true,
// Views to activate
views: {
list: true,
thumbs: true, // Show thumbs
active: 'thumbs'
},
// Flash settings
flash_swf_url: '/App_Themes/js/Moxie.swf',
// Silverlight settings
silverlight_xap_url: '/App_Themes/js/Moxie.xap',
init: {
UploadComplete: function (up, files) {
// Called when all files are either uploaded or failed
up.destroy();
initUploader();
UploadComplete();
}
}
});
// Handle the case when form was submitted before uploading has finished
$('#form').submit(function (e) {
// Files in queue upload them first
if ($('#uploader').plupload('getFiles').length > 0) {
// When all files are uploaded submit form
$('#uploader').on('complete', function () {
$('#form')[0].submit();
});
$('#uploader').plupload('start');
} else {
alert("You must have at least one file in the queue.");
}
return false; // Keep the form from submitting
});
};
function UploadComplete() {
var clickButton = document.getElementById("<%= _imagesButton.ClientID %>");
clickButton.click();
}
$(document).ready(function () { initUploader(); });
up.refresh();
</script>
<p>Please ensure you upload ALL photos at the same time, you may only press start upload ONCE, thanks.</p>
<div id="uploader" style="width: 100%!important;">
<p>Your browser doesn't have Flash, Silverlight or HTML5 support.</p>
</div>
//当DOM就绪时初始化小部件
var initUploader=函数(){
$(“#上传器”).plupload({
//一般设置
运行时:“html5、flash、silverlight、html4”,
url:“/Account/Upload.ashx”,
//用户一次最多只能上载20个文件(将多个_队列设置为false)
//最大文件数:10,
块大小:“1mb”,
//如果可以,在客户端调整图像大小
调整大小:{
宽度:800,
身高:600,
质量:90,
裁剪:真//裁剪到精确尺寸
},
多个_队列:正确,
过滤器:{
//最大文件大小
最大文件大小:“10mb”,
//指定要浏览的文件
mime_类型:[
{标题:“图像文件”,扩展名:“jpg、gif、png、jpeg”},
{标题:“Zip文件”,扩展名:“Zip”}
]
},
//如果可以,在客户端调整图像大小
调整大小:{宽度:800,高度:600,质量:90},
//通过单击文件标题重命名文件
重命名:对,
//排序文件
可排序:是的,
//允许将文件拖放到小部件上(目前只有HTML5支持此功能)
德拉格德罗普:没错,
//要激活的视图
观点:{
列表:正确,
拇指:true,//显示拇指
活动:“拇指”
},
//闪光设置
flash_swf_url:'/App_Themes/js/Moxie.swf',
//Silverlight设置
silverlight_xap_url:“/App_Themes/js/Moxie.xap”,
初始化:{
上传完成:功能(上传,文件){
//当所有文件上载或失败时调用
up.destroy();
initUploader();
上传完成();
}
}
});
//处理在上传完成前提交表单的情况
$('表格')。提交(功能(e){
//队列中的文件首先上载它们
if($('#uploader').plupload('getFiles').length>0){
//上传所有文件后,提交表单
$('#uploader')。on('complete',function(){
$('#form')[0]。提交();
});
$('上传器').plupload('开始');
}否则{
警报(“队列中必须至少有一个文件。”);
}
return false;//阻止表单提交
});
};
函数UploadComplete(){
var clickButton=document.getElementById(“”);
单击按钮。单击();
}
$(document).ready(函数(){initUploader();});
up.refresh();
请确保您同时上传所有照片,您只能按一次开始上传,谢谢
您的浏览器不支持Flash、Silverlight或HTML5
你好吗
我认为问题在于代码的这一部分:
UploadComplete: function (up, files) {
// Called when all files are either uploaded or failed
up.destroy();
initUploader();
UploadComplete();
}
我认为你应该使用:
UploadComplete: function (up, files) {
// Called when all files are either uploaded or failed
up.splice();
up.refresh();
UploadComplete();
}
在$.ready中,应该删除:“up.refresh()”