The implementation code of the new download filename of the uploaded file is renamed when ASP downloads-application Tips

Source: Internet
Author: User
Question: I want to upload the file renamed after the download, and then change the name back.
For example: I upload a "my photos. jpg" uploaded to the system after the number of "20040302001.jpg" download and then changed back to "my photos. jpg"
Both the old and new file names are in the database (done)
is to download the name of the change does not come out.

Code:
Copy 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 Examples:
Copy Code code as follows:

Call DL (Server.MapPath ("download/20040302001.jpg"), "my photos. jpg")
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.