84 lines
3.1 KiB
Plaintext
84 lines
3.1 KiB
Plaintext
<!-- #include Virtual = "/Lib/aspJSON1.17.asp" -->
|
|
<!-- #include Virtual = "/Lib/JSON_2.0.4.asp" -->
|
|
<!-- #include Virtual = "/Lib/JSON_UTIL_0.1.1.asp" -->
|
|
<%
|
|
Server.ScriptTimeout= 60 * 10
|
|
Dim JSON
|
|
|
|
Dim c_jsonText
|
|
|
|
set uploadform = Server.CreateObject("DEXT.FileUpload")
|
|
uploadform.AutoMakeFolder = True
|
|
Dim PKEY : PKEY = uploadform("PKEY")(1)
|
|
Dim IDKEY : IDKEY = uploadform("IDKEY")(1)
|
|
Dim VAR : VAR = uploadform("VAR")(1)
|
|
uploadform.DefaultPath = Server.MapPath("/ProjectUpload") & "\" & PKEY & "\" & IDKEY & "\" & VAR
|
|
|
|
file_cnt = uploadform("file_num").count
|
|
|
|
Redim j_cnt(file_cnt-1)
|
|
|
|
For i = 1 to file_cnt
|
|
IDKEY = uploadform("IDKEY")(i)
|
|
File_Name = uploadform("file_name")(i)'원본 File Name
|
|
File_Ext = Mid(File_Name, InStrRev(File_Name, "."))'원본 file 확장자
|
|
|
|
File_new_Name = IDKEY & "_" & VAR & "_" & uploadform("file_num")(i) & File_Ext 'New File name
|
|
File_Path = uploadform.DefaultPath & "\" & File_new_Name 'File save root
|
|
File_ori_name = File_Name
|
|
|
|
If uploadform.FileExists(File_Path) Then
|
|
File_Name_Only = IDKEY & "_" & VAR & "_" & uploadform("file_num")(i)
|
|
t = 0
|
|
Do While (1)
|
|
File_Path = uploadform.DefaultPath & "\" & File_Name_Only & "_" & t & File_Ext
|
|
If Not uploadform.FileExists(File_Path) Then Exit Do
|
|
t = t + 1
|
|
Loop
|
|
File_new_Name = File_Name_Only & "_" & t & File_Ext 'Not duplicated file name'
|
|
End If
|
|
|
|
if uploadform("file_name")(i).IsImageItem() = true Then
|
|
uploadform("file_name")(i).SaveAs(File_Path & "_ori")
|
|
Call makeThumbnail(uploadform.DefaultPath, File_Path & "_ori", File_new_Name)
|
|
uploadform.DeleteFile File_Path & "_ori"
|
|
Else
|
|
uploadform("file_name")(i).SaveAs(File_Path)
|
|
End If
|
|
|
|
set c_jsonText = jsObject()
|
|
c_jsonText("File_No") = i-1
|
|
c_jsonText("File_new_Name") = File_new_Name
|
|
c_jsonText("File_ori_Name") = File_ori_name
|
|
c_jsonText("File_Ext") = File_Ext
|
|
set j_cnt(i-1) = c_jsonText
|
|
NEXT
|
|
|
|
set JSON = jsObject()
|
|
json("count") = Ubound(j_cnt)
|
|
json("file_data") = j_cnt
|
|
|
|
Response.Write toJSON(JSON)
|
|
set uploadform = nothing
|
|
|
|
|
|
Function makeThumbnail(ByVal img_path, ByVal img_fpath, ByVal img_name)
|
|
Dim thumb_path, thumb_image, objImage, smal
|
|
smal = 1
|
|
'썸네일 이미지 생성
|
|
Set objImage = Server.CreateObject("DEXT.ImageProc")
|
|
IF objImage.SetSourceFile(img_fpath) Then
|
|
if objImage.ImageWidth > 5000 Or objImage.ImageHeight > 5000 Then
|
|
smal = 4
|
|
ElseIf objImage.ImageWidth > 3000 Or objImage.ImageHeight > 3000 Then
|
|
smal = 3
|
|
ElseIf objImage.ImageWidth > 1000 Or objImage.ImageHeight > 1000 Then
|
|
smal = 2
|
|
End if
|
|
thumb_path = img_path &"\"& img_name
|
|
thumb_image = objImage.SaveasThumbnail(thumb_path, objImage.ImageWidth / smal, objImage.ImageHeight / smal, false)
|
|
End IF
|
|
End Function
|
|
|
|
%>
|