0
I’m using the library Dropzone, it is working the only problem is that the selected files do not reach the server, always returns me Undefined index files, what 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'));
}
what is the result of
var_dump($_FILES['files']);
?– mercador
The PHP Error was encountered Severity: Notice Message: Undefined index: files
– viniciussvl
The name of your
input
isfiles[]
, you shouldn’t index the same way inphp
? Seria$_FILES['files[]']
– mercador
Of course not, this does not even exist face, I’m sending an array with the name files, in each position will an image
– viniciussvl