Use the current date as the serial number, using the function

Source: Internet
Author: User
Tags date current time save file
function | Serial number | function | Serial number <% ' The current date and time into the serial number
function Makefilename (fname)
FName = Now ()
fname = replace (fname, "-", "")
fname = replace (fname, "", "")
fname = replace (fname, ":", "")
fname = replace (fname, "PM", "")
fname = replace (fname, "AM", "")
fname = replace (fname, "a.m.", "")
fname = replace (fname, "PM", "")
Makefilename=fname
End Function
%>
On the function body, you can use this sentence vfname=makefilename (now ()) to invoke the current time call.
If Response.Write Vfname is displayed: Month and year day.


If the virtual upload to get the type of file uploaded, you can use the following function

<%
function Getextendname (FileName)
Dim extname
Extname = LCase (FileName)
Extname = Right (extname,3)
Extname = Right (Extname,3-instr (Extname, "."))
Getextendname = Extname
End Function
%>
This approach can be used when using function InStr to perform a comparison of uploaded file types
If Instr (". Gif.jpg.png", Getextendname) (file. FileName)) Then ' limits the type of upload file
' Typeflag = 1 ' file is a permitted type
Vfname = Makefilename (now ()) file performs this row for the allowed type
Fname=vfname & "." & Getextendname (file. FileName)
File. SaveAs Server.MapPath (upfilepath&fname) ' Save file
Else
' Typeflag = 0 ' file is not a permitted type

Response.Write ("<script language=javascript>")
Response.Write (' Alert (' does not support the type of file you are uploading! '); "
Response.Write ("History.back ();")
Response.Write ("</script>")
End If




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.