-
Notifications
You must be signed in to change notification settings - Fork 2
/
upload.asp
60 lines (49 loc) · 1.54 KB
/
upload.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<%@ Language=VBScript %>
<%
Option Explicit
Response.Expires = -1
Server.ScriptTimeout = 600
%>
<!-- #include file="freeaspupload.asp" -->
<%
' ****************************************************
' Change the value of the variable below to the pathname
' of a directory with write permissions, for example "C:\Inetpub\wwwroot"
Const StagingFolderPath = "staging"
Dim uploadsDirVar
uploadsDirVar = Server.MapPath(StagingFolderPath)
' ****************************************************
Function SaveFiles
Dim Upload, fileName, fileSize, ks, i, fileKey
Set Upload = New FreeASPUpload
Upload.Save(uploadsDirVar)
' If something fails inside the script, but the exception is handled
If Err.Number<>0 Then Exit Function
SaveFiles = ""
ks = Upload.UploadedFiles.keys
If (UBound(ks) <> -1) Then
For Each fileKey In Upload.UploadedFiles.keys
If ValidateFile(Upload.UploadedFiles(fileKey).FileName) <> "" Then
SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName
End If
Next
Else
' The file name specified in the upload form does not correspond to a valid file in the system.
SaveFiles = ""
End If
End Function
function ValidateFile(FileName)
Dim FSO
Set FSO = server.createObject("Scripting.FileSystemObject")
Const FileExt = "rdtp"
Dim FuncRet
FuncRet = FileName
If FSO.GetExtensionName(FileName) <> FileExt Then
FSO.DeleteFile(uploadsDirVar & "/" & FileName)
FuncRet = ""
End If
Set FSO = Nothing
ValidateFile = FuncRet
End Function
Response.Write SaveFiles()
%>