J1C said:
How could I create a random filename for a single-use download? So, if
a user was to download a file from a site it would send them a unique
filename that could only be used once. That link would not be available
after the download completed.
Will this help? Watch for word-wrap.
This copies the file to be downloaded (once) to a unique, temporary
filename then displays a link to it which, when clicked, downloads
the file and deletes the temporary filename.
<%@ Language="VBScript" %>
<% Option Explicit
'*
Const cASP = "TempFile.asp"
Const cTMP = "TempFile.zip"
'*
Dim strGTN
Dim strRQS
strRQS = Request.QueryString()
Dim strRSV
strRSV = Request.ServerVariables("HTTP_HOST")
'*
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If strRQS = "" Then
strGTN = objFSO.GetTempName()
objFSO.CopyFile Server.MapPath(cTMP), Server.MapPath(strGTN)
Else
If strRSV <> "localhost" Then
Server.Execute strRQS
End If
objFSO.DeleteFile Server.MapPath(strRQS)
Response.End
End If
Set objFSO = Nothing
%>
<html>
<head>
<title><%=cASP%></title>
</head>
<body>
Click to download: <a href="<%=cASP%>?<%=strGTN%>"><%=strGTN%></a>
</body>
</html>