2016-06-14 197 views
0

我使用DropzoneJs上傳文件,一切工作正常,但如果我想從剪貼板添加文件到放區,我必須使用FileReader。是當我用戶FileReader。我想我得到以下錯誤「無法讀取屬性未定義‘previewTemplate’」無法讀取未定義屬性'previewTemplate'dropzone.js

我的懸浮窗代碼

Dropzone.options.dropzoneForm = { 
maxFiles: 9999, 
url: "ajax/uploader.aspx", 
init: function() { 
    this.on("maxfilesexceeded", function (data) { 
     var res = eval('(' + data.xhr.responseText + ')'); 
    }); 
    this.on("addedfile", function (file) { 
     var removeButton = Dropzone.createElement("<button>Remove file</button>"); 
     var _this = this; 
     removeButton.addEventListener("click", function (e) { 
      e.preventDefault(); 
      e.stopPropagation(); 
      _this.removeFile(file); 
     }); 
     file.previewElement.appendChild(removeButton); 
    }); 

    this.on("complete", function (file) { 
     if (file.name.indexOf(".jpg") > -1) { 
      uploadDoneimg("img", file); 
     } else if (file.name.indexOf(".png") > -1) { 
       else 
        { 
         ShowMessage('e', "Error p2i Convert !"); 
        } 
       } 
      }); 

     } 
    }); 


    this.on("drop", function (file) { 
     // alert("drop : " + file.name); 
    }); 


    } 
}; 


FileReaderJS.setupClipboard(document.body, { 
    accept: { 
     'image/*': 'DataURL' 
    }, 
    on: { 
     load: function (e, cfile) {   
      $(Dropzone).addfile(cfile); 
     } 
    } 
}); 

這種組合在以下鏈接

https://www.bitpixr.com/

回答

0

問題happend是定義拖放區。是當你想從剪貼板添加文件並將文件傳遞到放置區時,你必須初始化DropZone。以動態的方式,然後每一件事情都會正常工作

哦,不要忘記設置自動發現虛假:)

Dropzone.autoDiscover = false; 

var myDropZone = new Dropzone("div#dropzoneForm", {url:''}); 

FileReaderJS.setupClipboard(document.body, { 
    accept: { 
     'image/*': 'DataURL' 
    }, 
    on: { 
     load: function (e, cfile) {   
      $(Dropzone).addfile(cfile); 
     } 
    } 
}); 
相關問題