<script type="text/javascript">
/*
$(function(){
$("#btn").click(function(){
$("#file").trigger("click");
var form = $('form')[0];
var formData = new FormData(form);
$.ajax({
url: './file_upload.jsp',
processData: false,
contentType: false,
data: formData,
type: 'POST',
success: function(result){
alert("업로드 성공!!");
window.reload;
}
});
});
}); */
var sel_file;
$(document).ready(function() {
$("#input_img").on("change", handleImgFileSelect);
});
function handleImgFileSelect(e) {
var files = e.target.files;
var filesArr = Array.prototype.slice.call(files);
filesArr.forEach(function(f) {
if(!f.type.match("image.*")) {
alert("확장자는 이미지 확장자만 가능합니다.");
return;
}
sel_file = f;
var reader = new FileReader();
reader.onload = function(e) {
$("#img").attr("src", e.target.result);
//$("#none-pic").hide();
}
reader.readAsDataURL(f);
});
}
</script>