The title is a bit confusing. This question is being discussed in the group today. CSDN has the answer. Attached, friends who need it can refer to the following question: I want to change the name when uploading a file, and then change the name back when downloading.
For example: I uploaded a photo of myself.jpg. After uploading, it was changed to the system name 20040302001.jpg. When downloaded, it was changed back to my photo.jpg.
The database is used to save the old and new file names (already done)
It's just that I can't change the name when downloading.
Code:
Copy the code code as follows:
<%
function dl(f,n)
on error resume next
Set S=CreateObject(Adodb.Stream)
S.Mode=3
S.Type=1
S.Open
S.LoadFromFile(f)
if Err.Number> 0 then
Response.Status= 404
else
Response.ContentType= application/octet-stream
Response.AddHeader Content-Disposition: , attachment; filename= & n
Range=Mid(Request.ServerVariables( HTTP_RANGE ),7)
if Range= then
Response.BinaryWrite(S.Read)
else
S.position=Clng(Split(Range, - )(0))
Response.BinaryWrite(S.Read)
End if
end if
Response.End
end function
%>
Function usage example:
Copy the code code as follows:
call dl(Server.MapPath( download/20040302001.jpg ), my photos.jpg )