답변 5개 / 댓글 1개
채택된 답변
+20 포인트
일단은 그냥은 안됩니다.
기본 브라우저 값으로 보이기 때문에 커스텀을 이용하셔야 합니다.
아래 움짤 참고하세요

코드는 다음과 같습니다.
Copy
<style>
.file-input-wrapper {
position: relative;
overflow: hidden;
display: inline-block;
}
.file-input-button {
border: 1px solid #ccc;
color: #333;
background-color: #f9f9f9;
padding: 5px 10px;
cursor: pointer;
}
.file-input {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
font-size: 100px;
cursor: pointer;
opacity: 0;
filter: alpha(opacity=0);
}
.file-name {
margin-left: 10px;
}
</style>
<div class="file-input-wrapper">
<button class="file-input-button">Select File</button>
<input type="file" class="file-input" id="file-input">
<span class="file-name">No file selected</span>
</div>
<script>
document.getElementById('file-input').addEventListener('change', function() {
var fileName = this.files[0] ? this.files[0].name : 'No file selected';
document.querySelector('.file-name').textContent = fileName;
});
</script>
답변을 작성하려면 로그인이 필요합니다.
