将此表单标记放置在何处


where to place this form tag

下面是关于如何在每行中添加文件输入和问题编号的代码:

var qnum = 1;
function insertQuestion(form) {   

    var $tbody = $('#qandatbl > tbody'); 
    var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
    var $qid = $("<td class='qid'>" + qnum + "</td>");
    var $image = $("<td class='image'></td>");

            var $imagefile = $('<input />')
        .attr({
            type: 'file',
            name: 'imageFile',
            class: 'imageFile'
        });
        $image.append($imagefile);
            var $imageclear = $('<input />')
        .attr({
            type: 'button',
            name: 'imageClear',
            class: 'imageClear',
            value: 'Clear File'
        });
        $image.append($imageclear);

    $tr.append($qid);
    $tr.append($image);   
    $tbody.append($tr); 
}

下表中添加了表格行:

<form id="enter" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return validateForm(this);" >

<div id="details">
<table id="qandatbl" align="center">
<thead>
<tr>
    <th class="qid">Question No</th>
    <th class="image">Image</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</form>

我想知道的是,我应该把这些代码放在下面的哪里,这样我就可以开始在服务器端检查文件了?我无法替换当前的标签,因为我需要表单标签。

   <form enctype="multipart/form-data" action="uploader.php" method="POST"> 
$fileType = $_FILES['imageFile']['type'];
if (!in_array($fileType, $allowedImageTypes)) { 
    echo "Unsupported file type";
}
else
{
    // Process the file
}

同一个表单不能有两个表单标记。相反,将enctype="multipart/form-data"添加到现有的<form>标记中,并在现有表单的处理逻辑中添加处理逻辑。