Problems uploading images with the dropzone library

0

I'm using the dropzone library, it's working the only problem is that the selected files do not reach the server, it always returns me Undefined index files , which could be ?

The form looks like this:

<h4 class="card-title">Escolha as imagens do seu anúncio</h4>
<form method="POST" id="myFirstDropzone" action="<?= base_url('Anunciante/adicionarImagens'); ?>" class="dropzone" enctype="multipart/form-data">
    <div class="fallback"> 
      <input name="files[]" type="file" multiple> 
    </div>
</form>

JavaScript

 Dropzone.options.myFirstDropzone = {
            paramName: "files", 
            maxFilesize: 2, // MB
            autoProcessQueue: false,
            uploadMultiple: true,
            parallelUploads: 3,
            maxFiles: 3
});


$("#btn-adicionar-img").click(function(){
   $("#myFirstDropzone").submit(); 
});

Controller

public function adicionarImagens(){
    echo '<pre>';
    var_dump($_FILES['files']);
    echo '</pre>';
    die();
    $this->anunciante->adicionaImagens($_FILES['files'], $this->session->userdata('id_anuncio'));
}
    
asked by anonymous 03.06.2017 / 23:49

1 answer

0

I was able to do this as follows

<form method="POST" enctype="multipart/form-data" id="myFirstDropzone" action="<?= base_url('Anunciante/adicionarImagens'); ?>" class="dropzone">

                </form><button type="button" id="btn-upload" class="btn btn-primary">Salvar imagens</button>

Clicking the button will start uploading the files:

  Dropzone.autoDiscover = false;

        var myDropzone = new Dropzone('#myFirstDropzone', {
            paramName: "files",
            maxFilesize: 3.0,
            maxFiles: 4,
            parallelUploads: 10000,
            uploadMultiple: true,
            autoProcessQueue: false
        });

        $('#btn-upload').on('click', function () {
            myDropzone.processQueue();
        });

Well simple people, whoever you need is there!

    
04.06.2017 / 01:09