I have a form that I'm testing that I want the user to be able to upload as many files as they need.
Here's the form, I have the enctype set. The form is not auto closed /> . The server accepts uploaded files from other scripts and even from this script if the input fields are not generated on the fly.
<table class="add-table">
<tr>
<td colspan="3">
Input New Specification Details
<form method="post" action="specifications.php">
<input type="submit" value="Go Back" />
</form>
</td>
</tr>
<form action="specifications-add.php" method="post" enctype="multipart/form-data">
<tr>
<td><label>Specification Name:</label></td>
<td><input type="text" name="spec-name" value="<?php echo $spec_name; ?>" /></td>
<td rowspan="3" class="add-spec-save-cell"><input type="submit" name="save-new-spec" value="Save Specification" /></td>
</tr>
<tr>
<td><label>Specification Type:</label></td>
<td>
<input type="radio" name="spec-type" value="astm" />ASTM<br />
<input type="radio" name="spec-type" value="oem" />OEM<br />
<input type="radio" name="spec-type" value="none" />None
</td>
</tr>
<tr>
<td><label>Attachments:</label></td>
<td><button id="add-another-row">+ Add Row</button></td>
</tr>
<tr>
<td> </td>
<td colspan="2" id="attachments-cell">
<!-- Dynamic code appended here -->
</td>
</tr>
</form>
</table>
Here is the javascript (jQuery) that generates the form:
$("button#add-another-row").click(function () {
var newRow = "<div class='new-attachment-row'>";
newRow += "<input name='attachments[]' type='file' />";
newRow += "<button class='delete-btn'>Delete </button></div>";
$("td#attachments-cell").append(newRow);
return false;
});
If I just add a simple <input name="attachment" type="file"> to the the form, the $_FILES array gets populated. If I use the javascript to dynamically generate the script the $_FILES data is not populated and does not show any values when I call var_dump($_FILES);
Is this a known limitation or bug? I can't figure out what I'm doing wrong.
visual for your reference:

<form>around<tr>.