C# Dropzone.js已附加

C# Dropzone.js已附加,c#,jquery,asp.net-mvc,asp.net-mvc-5,dropzone.js,C#,Jquery,Asp.net Mvc,Asp.net Mvc 5,Dropzone.js,我已经在我的项目中实现了dropzone,一切都很好。除了浏览器决定在请求页面清晰时抛出错误外,我已将视图向下修剪,因为它相当长,但下面的HTML当前位于表单中,不确定这是否会导致问题,我只有一个对dropzone的引用,如图所示,dropzone.js包含在bundle配置中,并且仅出现一次 错误:ifthis.element.DropZone已附加新的ErrorDropzone 这是我的看法 <div class="form-group"> <div class="

我已经在我的项目中实现了dropzone,一切都很好。除了浏览器决定在请求页面清晰时抛出错误外,我已将视图向下修剪,因为它相当长,但下面的HTML当前位于表单中,不确定这是否会导致问题,我只有一个对dropzone的引用,如图所示,dropzone.js包含在bundle配置中,并且仅出现一次

错误:ifthis.element.DropZone已附加新的ErrorDropzone

这是我的看法

<div class="form-group">
    <div class="col-xs-12 dropzone" id="UploadImage">
         <input type="file" id="id-input-file-2" />
     </div>
</div>
我的控制器如下

 public ActionResult SaveUploadedFile()
    {
        bool success = true;

        string fName = string.Empty;

        try
        {
            foreach (var file in Request.Files.Cast<string>().Select(fileName => Request.Files[fileName]).Where(file => file != null))
            {
                fName = file.FileName;

                if (file.ContentLength > 0)
                {
                   // will write the rest of the code here
                }
            }
        }
        catch (Exception ex)
        {
            success = false;
        }

        return Json(success ? new { Message = fName } : new { Message = "Error in saving file" });
    }
但我仍然会出错。

全局关闭自动发现,如下所示:Dropzone.autoDiscover= 错误的或

关闭特定元素的自动发现,如下所示: Dropzone.options.myAwesomeDropzone=false


从UploadImage元素的class属性中删除dropzone,错误就会消失。我也有同样的问题,这就解决了


我认为您将autoDiscover设置为false,并将元素的类设置为dropzone,这是给插件的混合消息。

这是唯一对我有效的解决方案

我最后做的是将css类重命名为dropzone1,然后在basic.cs和dropzone.cs文件中将dropzone的所有实例重命名为dropzone1。这样我就保留了所有的CSS样式


一旦我这么做了,它就发挥了巨大的作用。

我已经尝试过了,并用新的Jquery更新了我的问题,但我仍然会出错?!?!我已将您的建议置于我的Dropzone实现之上
 public ActionResult SaveUploadedFile()
    {
        bool success = true;

        string fName = string.Empty;

        try
        {
            foreach (var file in Request.Files.Cast<string>().Select(fileName => Request.Files[fileName]).Where(file => file != null))
            {
                fName = file.FileName;

                if (file.ContentLength > 0)
                {
                   // will write the rest of the code here
                }
            }
        }
        catch (Exception ex)
        {
            success = false;
        }

        return Json(success ? new { Message = fName } : new { Message = "Error in saving file" });
    }
$(document).ready(function () {

        Dropzone.options.myAwesomeDropzone = false;

        $("div#UploadImage").dropzone({
            url: '@Url.Action("SaveUploadedFile", "Person")',
            addRemoveLinks: true,
            removedfile: function (file) {
                var name = file.name;
                $.ajax({
                    type: 'POST',
                    url: '@Url.Action("DeleteUploadedFile", "Person")',
                    data: "id=" + name,
                    dataType: 'html'
                });
                var ref;
                return (ref = file.previewElement) != null ? ref.parentNode.removeChild(file.previewElement) : void 0;
            },
            maxFilesize: 2,
            maxFiles: 12,

        });
});