javascript - Dropzone image upload error display how to remove error - Stack Overflow

Notes : i tired all questions & answerrelated thistopic.I want to remove HTML data in popup aft

Notes : i tired all questions & answer related this topic.

I want to remove HTML data in popup after upload img or other document in Dropzone .

Dropzone uploed file accepted are assign var accept = ".png"; Work Fine. see code Here .But after image or other file upload then some html are display

snippet Example Below.

var accept = ".png";
Dropzone.autoDiscover = false;

// Dropzone class:
var myDropzone = new Dropzone("#mydropzone", { 
  url: "/file/post",
   acceptedFiles: accept,
   uploadMultiple: false,
   createImageThumbnails: false,
   addRemoveLinks: true,
    maxFiles: 3,
    maxfilesexceeded: function(file) {
        this.removeAllFiles();
        this.addFile(file);
    }
  
  });
<script src=".3.0/dropzone.js"></script>
<link href=".3.0/dropzone.css" rel="stylesheet"/>
<link href=".3.0/basic.css" rel="stylesheet"/>
<script src=".1.1/jquery.min.js"></script>
<div class="clsbox-1" runat="server"  >
		<div class="dropzone clsbox" id="mydropzone">

		</div>
	</div>

Notes : i tired all questions & answer related this topic.

I want to remove HTML data in popup after upload img or other document in Dropzone .

Dropzone uploed file accepted are assign var accept = ".png"; Work Fine. see code Here .But after image or other file upload then some html are display

snippet Example Below.

var accept = ".png";
Dropzone.autoDiscover = false;

// Dropzone class:
var myDropzone = new Dropzone("#mydropzone", { 
  url: "/file/post",
   acceptedFiles: accept,
   uploadMultiple: false,
   createImageThumbnails: false,
   addRemoveLinks: true,
    maxFiles: 3,
    maxfilesexceeded: function(file) {
        this.removeAllFiles();
        this.addFile(file);
    }
  
  });
<script src="https://cdnjs.cloudflare./ajax/libs/dropzone/4.3.0/dropzone.js"></script>
<link href="https://cdnjs.cloudflare./ajax/libs/dropzone/4.3.0/dropzone.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare./ajax/libs/dropzone/4.3.0/basic.css" rel="stylesheet"/>
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="clsbox-1" runat="server"  >
		<div class="dropzone clsbox" id="mydropzone">

		</div>
	</div>

Share edited Sep 29, 2016 at 6:21 Sumit patel asked Sep 29, 2016 at 4:59 Sumit patelSumit patel 3,90311 gold badges37 silver badges65 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

The error is caused because you are running the code in a fiddle, and dropzone is trying to upload the files to an url that doesn't exists.

When dropzone gets an error displays the message received by the server in the red popup, in this case is an html page.

This will not happen when you upload the files to a valid url.

You can change the text in the popup like this.

var myDropzone = new Dropzone("#mydropzone", {
  url: "/file/post",
  acceptedFiles: accept,
  uploadMultiple: false,
  createImageThumbnails: false,
  addRemoveLinks: true,
  maxFiles: 3,
  maxfilesexceeded: function(file) {
    this.removeAllFiles();
    this.addFile(file);
  },
  init: function() {
    this.on('error', function(file, errorMessage) {
      if (errorMessage.indexOf('Error 404') !== -1) {
        var errorDisplay = document.querySelectorAll('[data-dz-errormessage]');
        errorDisplay[errorDisplay.length - 1].innerHTML = 'Error 404: The upload page was not found on the server';
      }
    });
  }
});

Or while you are in a fiddle you can just pretend the upload was successful by just changing a class.

init: function() {
  this.on('error', function(file, errorMessage) {
    if (file.accepted) {
      var mypreview = document.getElementsByClassName('dz-error');
      mypreview = mypreview[mypreview.length - 1];
      mypreview.classList.toggle('dz-error');
      mypreview.classList.toggle('dz-success');
    }
  });
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743682342a4489586.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信