Advertisement
Guest User

Untitled

a guest
Dec 25th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. TypeError: Argument 2 of FormData.append is not an object.
  2. formData.append(this._getParamName(i), files[i], "");
  3.  
  4. <script>
  5. Dropzone.options.myDropzone = {
  6. autoProcessQueue: false,
  7. uploadMultiple: true,
  8. parallelUploads: 100,
  9. maxFiles: 1,
  10. maxFilesize: 10, //mb
  11. acceptedFiles: 'image/*',
  12. addRemoveLinks: true,
  13. autoDiscover: false,
  14. previewsContainer: '.dropzone-previews',
  15. clickable: '.dz-clickable', to showup the file select dialog box
  16.  
  17. accept: function(file, done) {
  18. done();
  19. },
  20.  
  21. // The setting up of the dropzone
  22. init: function() {
  23. var myDropzone = this;
  24.  
  25. this.on("error", function(file, message) {
  26. alert(message);
  27. this.removeFile(file);
  28. });
  29.  
  30. // Get Files from Server
  31. $.getJSON('listfiles', {aid: ID}, function(data) {
  32.  
  33. if(data[0] != false)
  34. {
  35. $.each(data, function(key, val) {
  36.  
  37. var mockFile = { name: val.name, size: 11 };
  38. myDropzone.options.addedfile.call(myDropzone, mockFile);
  39. myDropzone.options.thumbnail.call(myDropzone, mockFile, "/uploads/tmp/" + val.name);
  40. myDropzone.files.push(mockFile);
  41.  
  42. });
  43.  
  44. var existingFileCount = myDropzone.files.length; // The number of files already uploaded
  45. myDropzone.options.maxFiles = myDropzone.options.maxFiles - existingFileCount;
  46.  
  47. }
  48. });
  49.  
  50. $('#myDropzone').on("submit", function(e) {
  51. e.preventDefault();
  52. e.stopPropagation();
  53.  
  54. if (myDropzone.getQueuedFiles().length > 0) {
  55. myDropzone.processQueue();
  56. } else {
  57. myDropzone.uploadFiles([]); //send empty
  58. }
  59. });
  60.  
  61. this.on("removedfile", function(file) {
  62.  
  63. $.ajax({
  64. url: 'deleteimage',
  65. cache: true,
  66. dataType: 'json',
  67. data: { aid: advertID,iid: file.name },
  68. });
  69. var existingFileCount = myDropzone.files.length; // The number of files already uploaded
  70. myDropzone.options.maxFiles = myDropzone.options.maxFiles + 1;
  71.  
  72. });
  73.  
  74. if (files[0].status === Dropzone.CANCELED) {
  75.  
  76. if (files[0] && files[0].status === Dropzone.CANCELED) {
  77.  
  78. formData.append(this._getParamName(i), files[i], files[i].name);
  79.  
  80. if(typeof files[i] != "undefined"){
  81. formData.append(this._getParamName(i), files[i], files[i].name);
  82. }else{
  83. formData.append(this._getParamName(i), files[i], "");
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement