-5
下面是對文件的輸入問題編號是如何在每行中添加代碼:在哪裏放置這種形式的標籤
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
}
你不能有兩個形式標籤爲一個單一的形式... – ceejayoz 2012-02-08 17:06:30
如果你不能有2個表單標籤,然後我在哪裏把這個PHP代碼我已經把我的問題的編輯,檢查文件類型? – user1182476 2012-02-08 17:12:20
我是否只需要將enctype標籤包含在原始表單標籤中並將php放在同一頁面中? – user1182476 2012-02-08 17:17:40