파일명 수정
This commit is contained in:
parent
795f740ee9
commit
888eaba2e9
@ -111,23 +111,26 @@ const write = async () => {
|
|||||||
const boardId = boardResponse.data.CMNBRDSEQ;
|
const boardId = boardResponse.data.CMNBRDSEQ;
|
||||||
|
|
||||||
if (attachFiles.value && attachFiles.value.length > 0) {
|
if (attachFiles.value && attachFiles.value.length > 0) {
|
||||||
for (const file of attachFiles.value) {
|
for (const file of attachFiles.value) {
|
||||||
const formData = new FormData();
|
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);
|
|
||||||
|
|
||||||
await axios.post(`board/${boardId}/attachments`, formData, {
|
// 파일 이름에서 확장자 제거
|
||||||
headers: {
|
const fileNameWithoutExt = file.name.replace(/\.[^/.]+$/, ''); // 정규식을 사용하여 확장자 제거
|
||||||
'Content-Type': 'multipart/form-data',
|
|
||||||
},
|
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('게시물이 작성되었습니다.');
|
alert('게시물이 작성되었습니다.');
|
||||||
goList();
|
goList();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user