//----------------------------------------------------------------- // Dropzone options //----------------------------------------------------------------- //# Prevent Dropzone from auto discovering this element. This is useful //# when you want to create the Dropzone programmatically later. //Dropzone.options.myDropzone = false; // //# Disable auto discover for all elements: //Dropzone.autoDiscover = false; //# "myAwesomeDropzone" is the camelized version of the HTML element's ID //# Eg: Dropzone.options.myAwesomeDropzone = { ... } Dropzone.options.dropzone1 = { url: "upload.php", // Set the target url paramName: "file", // The name that will be used to transfer the file maxFilesize: 2, // MB thumbnailWidth: 80, thumbnailHeight: 80, parallelUploads: 20, dictDefaultMessage: "Drop files here or click to upload", previewTemplate: previewTemplate, //previewTemplate: document.querySelector('#preview-template').innerHTML, //autoQueue: false, // Make sure the files aren't queued until manually added //previewsContainer: "#previews", // Define the container to display the previews //clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files. accept: function(file, done) { var errMsg = validateTargetFilename(file.name); if (errMsg.length > 0) { done(errMsg); console.log(errMsg); $("#cmd-status").html(''); } else if (file.name.indexOf(" ") > -1) { // check whether filename has spaces file.name = file.name.replace(" ", "_"); // we get rid of spaces to avoid errors console.log("File name has spaces: [" + file.name +"]. It needs to be cleaned up."); //done("Invalid target file name for [" + file.name + "]. \nCannot upload file. \n\nFile name contains spaces."); done(); $("#cmd-status").html(''); } else { done(); $("#cmd-status").html(''); } }, init: function() { this.on("addedfile", function(file) { var errMsg = validateTargetFilename(file.name); if (errMsg.length > 0) { //alert(errMsg); //$("#dlg-title").html("File Upload"); //$("#dlg-body").html(errMsg); //$("#dlg").modal('show'); } console.log("Added file: targetname [" + file.name + "], " + "name [" + file.name + "], type [" + file.type + "], size [" + file.size + "]" ); }); } };