Implementation Code for renaming a new downloaded file name of an uploaded file during ASP download

Source: Internet
Author: User

Q: I want to change the name after uploading the file, and change the name after downloading.
For example, success"
The new and old file names are saved in the database (already done)
That is, the name of the downloaded file cannot be changed.

Code:Copy codeThe Code is 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 example:Copy codeThe Code is 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.