ASP.Net/JQuery:上传图片后不会触发PLUploader“添加文件” - c#

嗨,我一直在为asp.net c#使用PLUploader控制器。它可以按预期工作(它会首先出现),但是一旦我上传了文件,控制器就会禁用“添加文件”按钮(否则该按钮不起作用),并且我无法添加更多图像。

有人可以帮忙吗?我在下面发布了我认为错误出现的代码,但是如果需要任何其他代码,请问我将编辑该帖子。

谢谢

 <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>

参考方案

你好吗?

我认为问题是代码的这一部分:

 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()”。

asp.net使用客户端验证而不发布到服务器 - c#

我有一个很长的表格,分为几个部分。我想利用内置的ASP.NET验证控件而不在提交表单之前将其回发到服务器。为了提供更多的上下文,让我解释一下我的想法。该表格分为几部分,每个部分都有一个“下一步”按钮。单击“下一步”按钮时,将使用ASP.NET包含的客户端代码来验证该部分。如果该部分有效,则jquery方法将隐藏该部分并显示下一个。当用户到达表单的最后部分时,…

ASP.NET MVC 5自定义登录,无需脚手架,数据库优先 - c#

我对asp.net和mvc还是很陌生,所以我正在努力学习尽可能多的知识...为此,我从头开始编写博客网站,但是我对身份验证和授权有些困惑。由于我倾向于不真正使用任何脚手架的东西,所以我首先要使用数据库,所以不希望asp.net身份为我创建表。我对散列和加盐密码很酷,并对照数据库检查用户,我遇到的麻烦是将用户设置为登录状态并检查他们应该能够访问什么。我真的很想…

ASP.NET-如何更改JSON序列化的方式? - javascript

我正在使用ASP.NET通过以下查询返回Json文件:public ActionResult getTransactionTotals(int itemID) { DBEntities db = new DBEntities(); var query = from trans in db.Transactions // Linq query removed …

asp.net oledbcommand返回所有行 - c#

我正在使用Oledbconnection连接到Microsoft Access数据库,并且正在使用OleDbCommand检索一些信息。我在数据库中有一个名为retrieveInfo的查询,该查询检索3行数据。字段中有一些重复项,但是应该是这样。我的数据如下所示: Name Email A [email protected] B [email protected] B C@gmai…

ASP.NET MVC在控制器中实施分析 - c#

我有这个控制器public ActionResult Download(Guid? codice) { if (codice == null) { return HttpNotFound(); } string _pathfile = "path-to-file"; byte[] fileBytes = System.IO.File.Re…