반응형
$(document).ready(
$(function() {
$("#file_input4").on(
'change',
function() {
mappingPath = $(this).val();
console.log(mappingPath);
if (window.FileReader) {
var filename = $(this)[0].files[0].name;
} else {
var filename = $(this).val().split('/').pop()
.split('\\').pop();
}
$("#userfile4").val(filename);
});
})
);
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="<%=request.getContextPath()%>/resources/js/board.js"></script>
<script data-search-pseudo-elements defer
src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js"
crossorigin="anonymous"></script>
<div class="row mb-3">
<div class="col-8">
<div class="row">
<div class="col-10">
<input id="file_input4" filestyle="" type="file"
style="display: none"> <input type="text"
id="userfile4" class="form-control" name="userfile4"
disabled="">
</div>
<div class="col-2 p-0 m-0 d-flex justify-content-start align-items-center">
<label for="file_input4" class="btn btn-default"> <span
class="glyphicon fa fa-upload"></span>
</label>
<button type="button" class="btn-close" id="erase_btn4" aria-label="Close"></button>
</div>
</div>
</div>
</div>
반응형
'[JavaScript] > [JavaScript Code]' 카테고리의 다른 글
[JavaScript Code] 스피너 로딩화면 (0) | 2022.04.23 |
---|---|
[JavaScript Code] function 선언 방법 (document.ready(), window.onload) (0) | 2022.03.19 |
[JavaScript Code] 유효성체크 (한글, 숫자, 문자, 특수문자, 공백) (0) | 2022.03.06 |
[JavaScript Code] 예 아니오 Alert 기능 (0) | 2022.03.06 |
[JavaScript Code] ajax 페이지네이션 (0) | 2022.03.01 |