안녕하세요! 그누초보 입니다.
글쓴 후 첨부파일 삭제하는 체크 버튼은 있지만
처음 글쓰기할때 첨부파일을 선택 후 잘못선택해서 선택한 파일을 취소(삭제) 할수 있는 버튼을 만들고 싶습니다.
도움 부탁드립니다.
////////////////////////
<div class="row">
<?php for ($i=0; $is_file && $i<$file_count; $i++) { ?>
<div class="col-xs-12 col-input">
<div class="input-group input-group-sm">
<span class="input-group-addon input-group-addon-sm">파일 #<?=$i+1 ?></span>
<?php
if($w == 'u' && $file[$i]['file'])
$msg = $file[$i]['source'].' ('.$file[$i]['size'].')';
else
$msg = $upload_max_filesize.' 이하의 파일만 업로드 가능';
?>
<input type="text" class="form-control input-sm input-file" placeholder="<?=$msg?>" readonly>
<span class="input-group-btn">
<span class="btn btn-primary btn-file">
<i class="glyphicon glyphicon-folder-open"></i> 파일선택<input type="file" name="bf_file[]">
</span>
</span>
</div>
<?php if ($is_file_content) { ?>
<input type="text" name="bf_content[]" value="<?=($w == 'u') ? $file[$i]['bf_content'] : ''; ?>" placeholder="파일 설명을 입력해주세요." class="form-control input-sm" style="margin-top: 5px;">
<?php } ?>
<?php if($w == 'u' && $file[$i]['file']) { ?>
<label class="input"><input type="checkbox" id="bf_file_del<?=$i ?>" name="bf_file_del[<?=$i; ?>]" value="1"> 이 첨부파일을 삭제</label>
<?php } ?>
</div>
<?php } ?>
</div>
글쓴 후 첨부파일 삭제하는 체크 버튼은 있지만
처음 글쓰기할때 첨부파일을 선택 후 잘못선택해서 선택한 파일을 취소(삭제) 할수 있는 버튼을 만들고 싶습니다.
도움 부탁드립니다.
////////////////////////
<div class="row">
<?php for ($i=0; $is_file && $i<$file_count; $i++) { ?>
<div class="col-xs-12 col-input">
<div class="input-group input-group-sm">
<span class="input-group-addon input-group-addon-sm">파일 #<?=$i+1 ?></span>
<?php
if($w == 'u' && $file[$i]['file'])
$msg = $file[$i]['source'].' ('.$file[$i]['size'].')';
else
$msg = $upload_max_filesize.' 이하의 파일만 업로드 가능';
?>
<input type="text" class="form-control input-sm input-file" placeholder="<?=$msg?>" readonly>
<span class="input-group-btn">
<span class="btn btn-primary btn-file">
<i class="glyphicon glyphicon-folder-open"></i> 파일선택<input type="file" name="bf_file[]">
</span>
</span>
</div>
<?php if ($is_file_content) { ?>
<input type="text" name="bf_content[]" value="<?=($w == 'u') ? $file[$i]['bf_content'] : ''; ?>" placeholder="파일 설명을 입력해주세요." class="form-control input-sm" style="margin-top: 5px;">
<?php } ?>
<?php if($w == 'u' && $file[$i]['file']) { ?>
<label class="input"><input type="checkbox" id="bf_file_del<?=$i ?>" name="bf_file_del[<?=$i; ?>]" value="1"> 이 첨부파일을 삭제</label>
<?php } ?>
</div>
<?php } ?>
</div>
답변 1개 / 댓글 2개
채택된 답변
+20 포인트
기존 파일 첨부버튼 .... 적당한 위치에 추가합니다.
<button type="button" class="btn_file_del" onclick="delFile(<?php echo $i+1 ?>)">선택 취소</button>
write.skin.php 하단에 자바스크립트 코드를 추가
<script>
function delFile(idx) {
var fileInput = document.getElementById('bf_file_' + idx);
if (fileInput) {
// file input 값 초기화 (브라우저 호환성)
fileInput.value = "";
// IE 등 구형 브라우저 대응을 위해 한번 더 처리
fileInput.outerHTML = fileInput.outerHTML;
alert(idx + "번 첨부파일 선택이 취소되었습니다.");
}
}
</script>
참고해 보세요.
답변에 대한 댓글 2개
1주 전
답변을 작성하려면 로그인이 필요합니다.
새해 복 많이 받으세요~