diff --git a/B03_FileInput/B03_FileInput_UI_Page.ts b/B03_FileInput/B03_FileInput_UI_Page.ts index 1e4966df..60d6b3b2 100644 --- a/B03_FileInput/B03_FileInput_UI_Page.ts +++ b/B03_FileInput/B03_FileInput_UI_Page.ts @@ -268,10 +268,19 @@ export async function renderB03FileInput(root: HTMLElement): Promise { function onFileSelected(files: readonly File[], targetSlot?: FileSlot): void { if (files.length === 0) return; - // 이미 고른 슬롯을 다시 고르는 것은 "교체"라 총 개수가 늘지 않는다 — 그 슬롯을 빼고 센다. - // (빼지 않으면 5개를 다 고른 뒤 하나만 바꾸려 할 때 개수 초과로 막힌다.) - const occupied = selectedStates().filter((state) => state.slot !== targetSlot).length; - if (occupied + files.length > UPLOAD_MAX_FILES) { + // 개수는 "고른 파일 수"가 아니라 **최종적으로 차는 슬롯 수**로 센다. + // 같은 슬롯을 다시 고르는 것은 교체라 개수가 늘지 않는다 — 더하기로 세면 5개를 고른 + // 뒤 파일 선택 영역으로 하나만 바꾸려 해도 초과로 막힌다(2026-08-08). + const occupied = new Set(selectedStates().map((state) => state.slot)); + for (const file of files) { + const extension = getExtension(file.name); + const slot = + targetSlot ?? + Array.from(slots.values()).find((candidate) => candidate.extensions.includes(extension)) + ?.slot; + if (slot) occupied.add(slot); + } + if (occupied.size > UPLOAD_MAX_FILES) { pageError.textContent = L("B03_File_Error_Count"); return; }