[Solved] How to create more form fields by using javascript and then passing values to PHP


maybe something like this:

var totalFields = <?=$total_fields?>;
var currentFields = 0;

var addMode = document.getElementById('addMore');
var form = docuement.getElementsByTagName('form')[0];

addMore.onclick = function() {
   if (currentFields >= totalFields) {
      return false;
   }
   var newField = document.createElement('input');
   newField.setAttribute('type', 'file');
   newField.setAttribute('name', 'file'+currentFields);
   form.appendChild(newField);
   currentFields++
}

and then

<?
   foreach ($_FILES as $file) {
      // i guess you know what you should do
   }
?>

not tested … just for example

solved How to create more form fields by using javascript and then passing values to PHP