A form with one upload link already defined
<form name="form1" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
Files to upload
<input name="file[]" type="file" multiple/><br>
<button class="add_more">Add More Files</button>
<input type="submit" value="Upload File" id="upload"/>
</form>
and I can add more links for more files if i wish
$(document).ready(function(){
$('.add_more').click(function(e){
e.preventDefault();
$(this).before("<input name='file[]' type='file'/ multiple><br>");
});
});
but after adding more links and files , when i process the form $_FILES array only contains the first file , from the link defined originally in the html.
the var_dump($_FILES) output is after uploading the file is
array(1) { ["file"]=> array(5) { ["name"]=> array(1) { [0]=> string(14) "xxxxxCV.doc" } ["type"]=> array(1) { [0]=> string(18) "application/msword" } ["tmp_name"]=> array(1) { [0]=> string(14) "/tmp/phph4u15e" } ["error"]=> array(1) { [0]=> int(0) } ["size"]=> array(1) { [0]=> int(63488) } } }
Is there a way to dynamically add file uploads that end up in $_FILES ?
If i put multiple file upload lines in the html and dont use the jquery adding a link, $_FILES contains multiple files .
max_file_uploads = 20
(php.ini)
there are (to me at least) good reasons why I need to store the files in the database rather than as a link
if i create a form with 2,3,4 etc links
ie
<input name="file[]" type="file" multiple/><br>
<input name="file[]" type="file" multiple/><br>
<input name="file[]" type="file" multiple/><br>
<button class="add_more">Add More Files</button>
<input type="submit" value="Upload File" id="upload"/>
</form>
i can upload the files and they are in $_FILES. If i start with one link and add more with jquery, only the file uploaded from the original HTML ( not those add with jquery) is in $_FILES