Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
How to prevent dropZone to go over maxFile after reload the page

I am using the maxFile parameter for DropZone to allow in maximum one picture in the dropzone. It's working as long we do not reload the page. During the reload we read the files from the server an add the file into the dropzone. If there then one picture in the dropzone, then we can add another picture. See the code below! Where is my mistake?

Dropzone.autoDiscover = false;


$("#Titelbild").dropzone({
  maxFiles: 1,
  maxFilesize: 2, // Filesize 2 MByte  
  addRemoveLinks: true,
  acceptedFiles: ".jpeg,.jpg,.png,.gif,.jfif",
  
removedfile: function(file) {
       var fileName = file.name; 
         
       $.ajax({
         type: 'post',
         url: 'Delete_picture.php',
         data: {name: fileName, request: 'delete'},
         sucess: function(data){
            console.log('success: ' + data);
            // alert(data);
         }
        });

        var _ref;
        return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
  },  

  init: function() { 
    myDropzone1 = this;
  
    $.ajax({
      url: 'Fetch_picture.php',
      type: 'post',
      data: {request: 'fetch'},
      dataType: 'json',      
      success: function(response){
        var filecounter = 0;

        $.each(response, function(key,value) {
          var mockFile = { name: value.name, size: value.size};
          myDropzone1.emit("addedfile", mockFile);
          myDropzone1.emit("thumbnail", mockFile, value.path);
          myDropzone1.emit("complete", mockFile);

          };

        });

    }
   
    });
    
  }
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Add this

myDropzone1.files.push(mockFile);

after your line

myDropzone1.emit("complete", mockFile);

This did the trick for me

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda