koipa_edu_2025-1/src/main/webapp/innorix/gnexam/changeFileName.html
2023-07-18 15:40:15 +09:00

55 lines
2.3 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../innorix.css">
<script src="../innorix.js"></script>
<script>
var control = new Object();
window.onload = function() {
// 파일전송 컨트롤 생성
control = innorix.create({
el: '#fileControl', // 컨트롤 출력 HTML 객체 ID
transferMode: 'both', // 업로드, 다운로드 혼합사용
installUrl: '../install/install.html', // Agent 설치 페이지
allowExtension: 'jpg', //jpg 확장자만 첨부 허용
uploadUrl: './changeFileName.jsp' // 업로드 URL
});
// 업로드 완료 이벤트
control.on('uploadComplete', function (p) {
console.log(p.files);
var f = p.files;
var r = "Upload complete\n\n";
for (var i = 0; i < f.length; i++ ) {
r += f[i].controlId + " " + f[i].clientFileName + " " + f[i].fileSize + "\n";
console.log('실제 저장된 파일명 : '+f[i].serverFileName);
}
alert(r);
var files = JSON.stringify(f);
var innoJquery = innorix._load("innoJquery");
innoJquery('form#f_write').append('<input type="hidden" name="files" id="files" value=\'' + files + '\' />');
//innoJquery('form#f_write').submit();
});
// 파일 첨부시 에러
control.on('addFileError', function (p) {
alert(p[0].message + "\n jpg 파일만 등록해주세요.");
});
};
</script>
</head>
<body>
<a href="../gnIndex.html">&larr; 예제 목록</a><br /><br />
<form action="result.jsp" id="f_write" name="f_write" method="post">
test1 : <input type="text" name="test1" />
</form><br />
<div id="fileControl"></div><br/>
<input type="button" value="단일 파일 추가" onclick="control.openFileDialogSingle();"/>
<input type="button" value="업로드" onclick="control.upload();"/>
</body>
</html>