0

I am making a form with over 35 input fields and files that need to be uploaded with the form that can be relevant to that form's reviewing later.

In order to upload multiple files I wrote this script inside the form:

<script type="text/javascript">

    function cancelFile(v){
        $(v).closest('.input_file').remove();
    }

    function addFile(){
       $('#files').append('<div class="input_file"><input name="attachment\[\]" type="file" ><img class="cancel_img" src="images/delete.png" onclick="cancelFile(this)"></div> ');
}

</script>
<input type="button" onclick="addFile()" value="Add file"><br><br>
<div id="files">
</div>

It basically appends an input of type file with the name attachment[] when an add file button is clicked, and a span that allows to cancel (remove) that input when clicked.

When I add only one file, all the POST data uploads fine: text, dates, files and all. But when I add multiple files, the POST request is empty: var_dump($_POST) shows me an empty array.

The form has enctype="multipart/form-data" declared.I also tried the uploading of multiple files in a separate test and it worked fine.

Anyone knows why my post ends up empty?

Cœur
  • 37,241
  • 25
  • 195
  • 267
vlatkozelka
  • 909
  • 1
  • 12
  • 27
  • 4
    [Change the maximum upload file size](http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size) – Mihai Matei May 23 '16 at 12:21
  • @MateiMihai That worked! I honestly thought about max size but didn't think that it would be in default as low as 2MB, my test is only about 3MB. Can you add an answer so I can accept? – vlatkozelka May 23 '16 at 12:31
  • glad it worked.. I could post an answer but it is better to mark the question as duplicate – Mihai Matei May 23 '16 at 15:36

0 Answers0