Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TypeError: Argument 2 of FormData.append is not an object.
- formData.append(this._getParamName(i), files[i], "");
- <script>
- Dropzone.options.myDropzone = {
- autoProcessQueue: false,
- uploadMultiple: true,
- parallelUploads: 100,
- maxFiles: 1,
- maxFilesize: 10, //mb
- acceptedFiles: 'image/*',
- addRemoveLinks: true,
- autoDiscover: false,
- previewsContainer: '.dropzone-previews',
- clickable: '.dz-clickable', to showup the file select dialog box
- accept: function(file, done) {
- done();
- },
- // The setting up of the dropzone
- init: function() {
- var myDropzone = this;
- this.on("error", function(file, message) {
- alert(message);
- this.removeFile(file);
- });
- // Get Files from Server
- $.getJSON('listfiles', {aid: ID}, function(data) {
- if(data[0] != false)
- {
- $.each(data, function(key, val) {
- var mockFile = { name: val.name, size: 11 };
- myDropzone.options.addedfile.call(myDropzone, mockFile);
- myDropzone.options.thumbnail.call(myDropzone, mockFile, "/uploads/tmp/" + val.name);
- myDropzone.files.push(mockFile);
- });
- var existingFileCount = myDropzone.files.length; // The number of files already uploaded
- myDropzone.options.maxFiles = myDropzone.options.maxFiles - existingFileCount;
- }
- });
- $('#myDropzone').on("submit", function(e) {
- e.preventDefault();
- e.stopPropagation();
- if (myDropzone.getQueuedFiles().length > 0) {
- myDropzone.processQueue();
- } else {
- myDropzone.uploadFiles([]); //send empty
- }
- });
- this.on("removedfile", function(file) {
- $.ajax({
- url: 'deleteimage',
- cache: true,
- dataType: 'json',
- data: { aid: advertID,iid: file.name },
- });
- var existingFileCount = myDropzone.files.length; // The number of files already uploaded
- myDropzone.options.maxFiles = myDropzone.options.maxFiles + 1;
- });
- if (files[0].status === Dropzone.CANCELED) {
- if (files[0] && files[0].status === Dropzone.CANCELED) {
- formData.append(this._getParamName(i), files[i], files[i].name);
- if(typeof files[i] != "undefined"){
- formData.append(this._getParamName(i), files[i], files[i].name);
- }else{
- formData.append(this._getParamName(i), files[i], "");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement