-5
아래는 파일 입력 및 질문 번호가 각 행에 추가하는 방법에 코드입니다 :는 곳이 양식 태그를 배치
<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>
: 아래
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 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
2 개의 양식 태그를 사용할 수없는 경우이 PHP 코드를 어디에 두어야합니까? 파일 형식을 검사하는 질문을 편집합니다. – user1182476
원래 폼 태그에 enctype 태그를 넣고 PHP를 같은 페이지에 넣기 만하면됩니까? – user1182476