Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
Dropzone is uploading all files to server for each file drop/selection

I'm trying to integrate dropzone in a laravel 8 application. Whenever I drop any image in dropzone, it is uploading all the files of dropzone, not skipping already uploaded file. For example, if I drop "image-1.jpg" in dropzone, it uploads the file instantly (which is desired). But after that, if I select "image-2.jpg", it re-uploads "image-1.jpg" first (which isn't desired, I want to prevent this re-upload), then it uploads "image-2.jpg". Also, I want to prevent folder(containing multiple image) upload and have tried to prevent it by setting maxFiles to 1, but it's not preventing it.

Javascript

    var refType = $('#reference-type');
    electronic = $('.electronic'),
    image = $('.image'), 
    description = $('.description'),
    url = "{{ route('user.bank.files') }}",
    submitRef = $('#submit-ref');
    
    Dropzone.autoDiscover=false;
    var imageDropzone;
    var config = { 
        url: url, headers: {'X-CSRF-TOKEN':'{{ csrf_token() }}'},
        uploadMultiple: false,
        maxFiles: 1,
        maxFilesize: 1,
        paramName: 'reference_image',
        addRemoveLinks: true,
        acceptedFiles: 'image/jpeg, image/png , image/jpg, image/svg',
        init: function() {
            imageDropzone = this;
        },
        removedfile: function (file) {
            if (file.accepted) {
                data = {
                    action: 'delete',
                    tnx_id: "{{ the_tnx(data_get($order, 'tnx')) }}"
                };
                NioApp.Form.toPost(url, data);
            }
            var _ref;
            return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
        },
        sending: function(data, xhr, formData) {
            formData.append('action', 'store');
            formData.append('tnx_id', "{{ the_tnx(data_get($order, 'tnx')) }}");
        },
        addedfiles: function () {
            if (this.files.length > 1) {
                this.removeFile(this.files[1]);
                NioApp.Toast("{{ __('You can upload only one :file.', ['file' => 'image']) }}", 'warning');
            }
        },
        error: function(file, errorMessage) {
            $.each(imageDropzone.files, function(i, file) {
                file.status = Dropzone.QUEUED
            });
        }
    };

    $("#reference-image").dropzone({...config});
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda