단일 파일 또는 여러 파일을 선택하면 결과가 동일합니다. 이 코드가 여러 파일을 업로드 할 것으로 기대하고 있습니다. 그러나 배열은 비어 있습니다. 다른 사람들이 여러 게시물을 검토 한 결과 해당 질문에 대한 답변이 여기에 적용되지 않는 것 같습니다. 'action'이라는 이름의 숨겨진 입력을 제외한 모든 양식 입력을 제거하면 업로드가 올바르게 작동합니다. PHP는 여기PHP : 여러 파일 업로드 : 공지 : 정의되지 않은 색인 : bulletin.php의 파일
<form action="bulletin.php" method="post" enctype="multipart/form-data">
<input class="form-control" id="message_subject" name="message_subject" type="text"/>
<textarea class="form-control" cols="40" id="message_body" name="message_body" rows="10"></textarea>
<input type="file" id="file" name="file[]" multiple accept="image/*"/>
<input type="hidden" name="action" value="submit_new">
<button class="btn btn-primary " name="submit" type="submit">Submit</button>
</form>
된다 :
어레이()
주의 : 여기서
print_r($_FILES);
if(isset($_POST['action'])){
// Count total files
$countfiles = count($_FILES['file']['name']);
// Looping all files
for($i=0;$i<$countfiles;$i++){
$filename = date('Y-m-d-H-i-s') . $_FILES['file']['name'][$i];
// Upload file
move_uploaded_file($_FILES['file']['tmp_name'][$i],'user-images/'.$filename);
}
}
가 출력된다 여기
는 relvant HTML 형식 인 불확정 인덱스 : 66 행의 /var/www/html/secure/bulletin.php에 파일
다른 입력이 양식에 포함되어있는 경우 왜 배열이 비어 있습니까?
_66_ 라인에 의견을 올려주세요. – andrewnagyeb
이 답변의 단계를 통해 확인하십시오 https://stackoverflow.com/a/3587158/689579 – Sean
줄을 표시하십시오. 66 – zstate