1 line
6.7 KiB
HTML
1 line
6.7 KiB
HTML
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<link rel="stylesheet" href="../innorix.css">
|
|
<script src="../innorix.js"></script>
|
|
<script>
|
|
var control = new Object();
|
|
innorix.setLanguage('ko');
|
|
var innoJquery = innorix._load("innoJquery");
|
|
|
|
window.onload = function() {
|
|
// 파일전송 컨트롤 생성
|
|
control = innorix.create({
|
|
el: '#fileControl', // 컨트롤 출력 HTML 객체 ID
|
|
transferMode: 'both', // 업로드, 다운로드 혼합사용
|
|
installUrl: '../install/install.html', // Agent 설치 페이지
|
|
uploadUrl: './upload.jsp' // 업로드 URL
|
|
, agent: true
|
|
});
|
|
control.on('onDblClickRows', function (file) { // 더블클릭 이벤트
|
|
if(file.mode == "upload"){
|
|
innorix.execute(file); // 파일실행 매서드
|
|
}
|
|
else if(file.mode == "download"){
|
|
control.downloadAndOpen(file); // 다운로드 후 바로열기
|
|
}
|
|
});
|
|
|
|
// 업로드 완료 이벤트
|
|
control.on('uploadComplete', function (p) {
|
|
alert("업로드가 완료 되었습니다.\n다운로드 가능하게 재구성 합니다.");
|
|
var urlBase = location.href.substring(0, location.href.lastIndexOf("/") + 1);
|
|
var fileArray = new Array();
|
|
var f = p.files;
|
|
console.log(p);
|
|
for (var i = 0; i < f.length; i++ ) {
|
|
var fileObj = new Object();
|
|
fileObj.printFileName = f[i].clientFileName;
|
|
fileObj.fileSize = f[i].fileSize;
|
|
fileObj.downloadUrl = urlBase + "download.jsp?fileFullPath=" + f[i].serverFilePath +"&fileName="+f[i].clientFileName;
|
|
fileObj.serverFilePath = f[i].serverFilePath;
|
|
fileObj.rootName = f[i].rootName;
|
|
fileArray.push(fileObj);
|
|
}
|
|
control.removeAllFiles(); // 리스트 컨트롤에서 파일을 삭제
|
|
control.presetDownloadFiles(fileArray); // 다운로드 목록을 구성
|
|
});
|
|
};
|
|
|
|
function fnUpload(){
|
|
|
|
// 트랜젝션별, 파일별 파라메터 전달, 저장경로 설정, 변경파일명 설정
|
|
var postObj = new Object(); //트랜잭션별
|
|
|
|
var fileInfo = control.getAllFiles(); //업로드, 다운로드파일정보 불러오기
|
|
if (fileInfo.length == 0 ) {
|
|
return;
|
|
}
|
|
|
|
var today = new Date().toISOString().slice(0,10).replace(/-/g,"\\");
|
|
//postObj.custParam1 = "\\innorix\\save\\"+today; // 저장경로 설정
|
|
control.setPostData(postObj); // 트랜잭션별 업로드시 함께 전달될 POST Param 추가
|
|
|
|
for (var i=0; i<fileInfo.length; i++){
|
|
var postObj2 = new Object(); //파일별 postdata 를 전달할 object 객체 생성
|
|
//postObj2.custParam2 = fileInfo[i].printFileName;
|
|
postObj2.custParam3 = i;
|
|
control.setFilePostDataByIndex(i, postObj2); // 파일별 postdata 로 값 저장
|
|
}
|
|
|
|
control.upload(); // 업로드 시작
|
|
}
|
|
|
|
function testt(){
|
|
control.addSelectFilesById(afFileId);
|
|
}
|
|
|
|
function fnZipDownload() {
|
|
|
|
var urlBase = location.href.substring(0, location.href.lastIndexOf("/") + 1);
|
|
|
|
var filePaths="";
|
|
var fileInfo = control.getDownloadFiles();
|
|
|
|
for(var i=0;i<fileInfo.length;i++) {
|
|
filePaths += fileInfo[i].serverFilePath+"!!@#";
|
|
}
|
|
console.log('dddddd');
|
|
console.log(filePaths);
|
|
console.log((Math.random()+"").substring(2,7)+".zip");
|
|
innoJquery.ajax({
|
|
type : "POST",
|
|
dataType : 'json',
|
|
data : {
|
|
"zipFileName" : (Math.random()+"").substring(2,7)+".zip",
|
|
"filePaths": filePaths
|
|
},
|
|
url : urlBase + "archFiles.jsp",
|
|
success : function(data) {
|
|
var fileObj = new Object();
|
|
var ar = new Array();
|
|
console.log(data);
|
|
fileObj.printFileName = data.zipFileName;
|
|
fileObj.fileSize = data.zipFileSize;
|
|
fileObj.downloadUrl = urlBase + "downloadTest.jsp?zipFileFullPath=" + data.zipFilePath + "&fileName=" + data.zipFileName
|
|
ar.push(fileObj);
|
|
control.presetDownloadFiles(ar);
|
|
//window.location.href = "downloadTest.jsp?zipFileFullPath=" + encodeURI(data.zipFilePath);
|
|
},
|
|
});
|
|
}
|
|
|
|
function fnSelectZipDownload() {
|
|
|
|
var urlBase = location.href.substring(0, location.href.lastIndexOf("/") + 1);
|
|
|
|
var filePaths="";
|
|
var fileInfo = control.getSelectedFiles();
|
|
console.log(fileInfo);
|
|
if(fileInfo.length<1){
|
|
return;
|
|
}
|
|
for(var i=0;i<fileInfo.length;i++) {
|
|
filePaths += fileInfo[i].serverFilePath+",";
|
|
}
|
|
|
|
innoJquery.ajax({
|
|
type : "POST",
|
|
dataType : 'json',
|
|
data : {
|
|
"zipFileName" : (Math.random()+"").substring(2,7)+".zip", //
|
|
"filePaths": encodeURI(filePaths)
|
|
//"filePk": filePk
|
|
},
|
|
url : urlBase + "archFiles.jsp",
|
|
success : function(data) {
|
|
window.location.href = "downloadTest.jsp?zipFileFullPath=" + encodeURI(data.zipFilePath);
|
|
//window.location.href = "download.jsp?filePk=" + data.zipFilePk;
|
|
},
|
|
});
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<a href="../index.html">← 예제 목록</a><br /><br />
|
|
|
|
<div id="fileControl"></div><br/>
|
|
|
|
<input type="button" value="파일추가" onclick="control.openFileDialog();"/>
|
|
<input type="button" value="폴더추가" onclick="control.openFolderDialog();"/>
|
|
<input type="button" value="업로드" onclick="fnUpload();"/>
|
|
<input type="button" value="선택파일 다운로드" onclick="control.downloadSelectedFiles();"/>
|
|
<input type="button" value="전체 다운로드" onclick="control.download();"/>
|
|
<input type="button" value="테스트" onclick="testt();"/>
|
|
<input type="button" value="선택압축 다운로드" onclick="fnSelectZipDownload();"/>
|
|
<input type="button" value="전체압축 다운로드" onclick="fnZipDownload();"/>
|
|
</body>
|
|
</html> |