0

Hey peaps using dropzone here to upload some files to my server. At the moment i configured it to not upload till i click the upload button so i can manage and rearange files in the queue. When i upload them, in my back end i get this array structure for my files:

$_FILES['file']['name'][0] == "my-first-file-name.xls"

$_FILES['file']['name'][1] == "my-second-file-name.sml"

$_FILES['file']['tmp_name'][0] == "my-first-file-tmp-name"

$_FILES['file']['tmp_name'][1] == "my-second-file-tmp-name"

I think the correct, as i used before with other technologies, is:

$_FILES['file'][0]['name']

$_FILES['file'][0]['tmp_name']

$_FILES['file'][1]['name']

$_FILES['file'][1]['tmp_name']

What am i doing wrong?

changing paramName: option to "files[]" doesnt work.

javascript

$(document).ready(function() {
    $("#button").click(function (e) {
        e.preventDefault()
        var myDropzone = Dropzone.forElement(".dropzone");
        myDropzone.processQueue()
    });
})

Dropzone.options.myAwesomeDropzone = { 
paramName: "file", 
maxFilesize: 5, 
uploadMultiple: true, 
maxFiles: 10, 
acceptedFiles: ".xls, .xml, .xlsx", 
addRemoveLinks: true, 
autoProcessQueue: false, 
parallelUploads: 10, 
dictDefaultMessage: "<strong>Arraste os arquivos aqui ou clique para selecionálos. </strong>", 
dictInvalidFileType: "Este tipo de arquivo não é permitido.", 
dictRemoveFile: "Remover"
};

html

<form action="/files/fileImport" class="dropzone" id="myAwesomeDropzone">   
</form>
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • 2
    I think if you just take a look at the [manual for PHP File Upload](https://www.php.net/manual/en/features.file-upload.post-method.php) It will all be explained – RiggsFolly Apr 05 '19 at 15:11
  • Or just do a `print_r($_FILE);` to find out what the relevant parts of the `$_FILES` array are called by DropZone – RiggsFolly Apr 05 '19 at 15:13

1 Answers1

1

No it's not wrong, Dropzone is powerful to upload multiple files, hence you are getting an array of names and tmp_names. You just have to write your code accordingly, i.e., loop through your arrays and save them in the backend. If You don't want that feature, you should change your setting accordingly

Dropzone.options.myAwesomeDropzone = { 
    paramName: "file", 
    maxFilesize: 5, 
    uploadMultiple: true, // change this to false
    maxFiles: 10, // here change this to 1
    acceptedFiles: ".xls, .xml, .xlsx", 
    addRemoveLinks: true, 
    autoProcessQueue: false, 
    parallelUploads: 10, 
    dictDefaultMessage: "<strong>Arraste os arquivos aqui ou clique para selecionálos. </strong>", 
    dictInvalidFileType: "Este tipo de arquivo não é permitido.", 
    dictRemoveFile: "Remover"
};
deviprsd
  • 378
  • 3
  • 12
  • mate read the question. my objective is to upload multiple files. if i do the changes u suggested i cant. – CamelCaseDamnUser Apr 05 '19 at 15:17
  • The thing is you aren't doing anything wrong, it's just how Dropzone works, changing the layout or adding event hooks will work for you https://www.dropzonejs.com/#layout or https://www.dropzonejs.com/#events – deviprsd Apr 05 '19 at 15:23