From 888eaba2e98186e30348b706f91d4ecdce9828de Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Tue, 21 Jan 2025 13:16:27 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EB=AA=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/board/BoardWrite.vue | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/views/board/BoardWrite.vue b/src/views/board/BoardWrite.vue index a091174..05e5514 100644 --- a/src/views/board/BoardWrite.vue +++ b/src/views/board/BoardWrite.vue @@ -111,23 +111,26 @@ const write = async () => { const boardId = boardResponse.data.CMNBRDSEQ; if (attachFiles.value && attachFiles.value.length > 0) { - for (const file of attachFiles.value) { - const formData = new FormData(); - formData.append('CMNBRDSEQ', boardId); - formData.append('CMNFLEORG', file.name); - formData.append('CMNFLEEXT', file.name.split('.').pop()); - formData.append('CMNFLESIZ', file.size); - formData.append('CMNFLEPAT', 'boardfile'); - formData.append('file', file); + for (const file of attachFiles.value) { + const formData = new FormData(); - await axios.post(`board/${boardId}/attachments`, formData, { - headers: { - 'Content-Type': 'multipart/form-data', - }, - }); - } + // 파일 이름에서 확장자 제거 + const fileNameWithoutExt = file.name.replace(/\.[^/.]+$/, ''); // 정규식을 사용하여 확장자 제거 + + formData.append('CMNBRDSEQ', boardId); + formData.append('CMNFLEORG', fileNameWithoutExt); // 확장자를 제거한 이름 + formData.append('CMNFLEEXT', file.name.split('.').pop()); // 확장자 + formData.append('CMNFLESIZ', file.size); // 파일 크기 + formData.append('CMNFLEPAT', 'boardfile'); // 파일 경로 + formData.append('file', file); // 실제 파일 데이터 + + await axios.post(`board/${boardId}/attachments`, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); } - + } alert('게시물이 작성되었습니다.'); goList(); } catch (error) {