Files
KIN/other/official_upload.asp
2025-09-29 17:55:08 +09:00

207 lines
5.8 KiB
Plaintext

<!-- #include virtual = "include/header.asp" -->
<!-- #include virtual = "include/left.asp" -->
<%
dim attach_file
dim FileSizeCheck
dim xup
dim countfilename
dim fileattach, filename, fileNameTemp, file , ext, filesize, bExist, upd
dim official_no : official_no = Request("official_no")
dim official_client : official_client = Request("official_client")
dim official_title : official_title = Request("official_title")
dim team_name : team_name = Request("team_name")
dim p_name : p_name = Request("p_name")
Dim FilePath
'업로드용 객체를 생성하는 부분입니다.
Set xup = Server.CreateObject("SiteGalaxyUpload.Form")
' 파일 관련 기본 콤포넌트를 생성하는 부분입니다.
set fso = server.createobject("scripting.filesystemobject")
'모든 폼의 request된 값은 사이트갤럭시에선 아래와 같이 받아야 합니다.
dim aa_official_no : aa_official_no = xup("official_no")
a_input_user = session("User_Number")
FileSizeCheck = 1 '업로드파일의 크기가 일단은 5Mbyte이하라고 가정
' 파일을 업로드했을 경우입니다.
fileattach = xup("txtFileName")
If fileattach <> "" then
' 저장할 디렉토리입니다. nt계정이라면 당근 everyone 계정에 write 퍼미션이 있어야 겠죠...^^
upd = Server.MapPath("/") & "\upload\official\"
'폴더가 존재하지 않을 경우 만듦
If (fso.FolderExists(upd)) Then
else
fso.CreateFolder(upd)' 해당 폴더가 없을 경우
End If
attach_file = fileattach.FilePath
' 올리는 파일이름만 뽑아내는 부분입니다. 이유야 뻔히 중복파일을 처리를 위해서죠...^^
filename = Mid(attach_file, instrRev(attach_file, "\") + 1)
filename = aa_official_no&"_"&filename
' 파일 이름만 구합니다.
file = Mid(filename, 1, instr(filename, ".") - 1)
'Response.Write filename&"///"&file
'Response.End
' 파일 확장자를 구합니다.
ext = Mid(filename, instr(filename, ".") + 1)
' 저장할 파일의 완전한 이름을 임시 변수에 저장합니다.
fileNameTemp = upd & filename
bExist = True
' 파일이 존재할 경우, 이름 뒤에 붙일 것입니다. 단순히 0부터 1씩 증가합니다.
countfilename = 0
While bExist
' 파일이 있으면, 여기로 들어 와서 파일 이름에 숫자를 붙인 새로운 파일 이름 생성합니다.
If (fso.FileExists(fileNameTemp)) Then
countfilename = countfilename + 1
fileNameTemp = upd & file & "_v" & countfilename & "." & ext
filename = file & "_v" & countfilename & "." & ext
' 파일이 존재하지 않을 경우
Else
bExist = False
End if
Wend
' FileSystemObject를 닫아줍니다.
'Set fso = nothing
' 위에서 구한 파일의 크기를 구합니다.
filesize = fileattach.Size
'204800 = 200kb
'5 * 200kb = 1mb
'204800 * 5 = 1024000(1Mbyte)
if filesize > 20480000 then '20Mbyte
FileSizeCheck = 0
else
FileSizeCheck = 1
' 파일을 실제로 업로드 받습니다.
fileattach.SaveAs fileNameTemp
end if
if FileSizeCheck = 1 then
query = ""
query = query & " update T_OFFICIAL_NO set "
query = query & " file_list = '" & filename & "', "
query = query & " file_size = '" & filesize & "', "
query = query & " input_user = '" & a_input_user & "' "
query = query & " where official_no = '" & aa_official_no &"' "
'Response.Write query
set dbin = server.CreateObject("ADODB.CONNECTION")
dbin.Open adoConn
dbin.Execute query
dbin.Close
'Alert_Back("파일 업로드 성공")
end if
' 파일 업로드를 안했을 경우입니다.
Else '' If fileattach <> "" then
filesize = 0
filename = ""
End if
'''log db에 쓰기
set xup = nothing
set fso = nothing
if filename <> "" Then
%>
<script>
alert("파일 첨부 성공");
window.opener.location.reload();
window.close();
</script>
<%
End If
if FileSizeCheck = 0 then '업로드 파일의 크기가 5Mbyte 이상이면
Alert_Back("첨부 파일의 크기가 20Mbyte보다 커서 저장이 되지 않습니다")
End If
%>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<h1>공문 번호 생성기</h1>
</div>
<!-- /.content-header -->
<!-- Main content -->
<div class="content-body">
<div class="content">
<div class="container-fluid">
<div class="row row-0">
<div class="col-12">
<form name="official_up" method="post" enctype="multipart/form-data">
<input type="hidden" name="official_no" id="official_no" value="<%=official_no %>" />
<table class="table table-sm table-sm2 table-bordered table-head tr-colors">
<tr>
<td colspan="2" class="text-center h5 py-2"> 공문파일 업로드 (PDF)</td>
</tr>
<tr>
<td class="text-center"><b>공문번호</b> </td>
<td>&nbsp;<%=official_no %></td>
</tr>
<tr>
<td class="text-center"><b>고객명</b> </td>
<td>&nbsp;<%=official_client %></td>
</tr>
<tr>
<td class="text-center"><b>제목</b> </td>
<td>&nbsp;<%=official_title %></td>
</tr>
<tr>
<td class="text-center"><b>담당 부서</b> </td>
<td>&nbsp;<%=team_name %></td>
</tr>
<tr>
<td class="text-center"><b>공문번호 생성자</b> </td>
<td>&nbsp;<%=p_name %></td>
</tr>
<tr>
<td class="text-center align-middle"><b>파일 업로드</b> </td>
<td><input type="file" name="txtFileName" id="txtFileName" class='form-control'></td>
</tr>
<tr>
<td colspan="2">
<button type="button" class="btn btn-primary btn-block" onclick="js_up();">저장</button>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- /.content -->
<!-- REQUIRED SCRIPTS -->
<script>
$(function(){
cutmenu();
});
function js_up(x) {
if (document.getElementById("txtFileName").value == "") {
alert("파일을 선택하여 주십시오.");
return false;
}else{
official_up.target = "";
official_up.action = "official_upload.asp";
official_up.submit();
}
}
</script>
</div>
<!-- /.content-wrapper -->
<!-- #include virtual = "include/footer.asp" -->