Adding a timestamp to a filename

Discussion in 'ASP General' started by kbrad, Sep 28, 2004.

  1. kbrad

    kbrad Guest

    I am uploading files to my webserver using an asp upload script and would
    like to add a timestamp just before they are saved to the server.
    This would mean that filename.txt on my server would be uploaded to the
    webserver as filenameYYMMDDhhmmss.txt or something similar.
    Can anyone advise how to do this?
    kbrad, Sep 28, 2004
    #1
    1. Advertising

  2. > I am uploading files to my webserver using an asp upload script and would
    > like to add a timestamp just before they are saved to the server.
    > This would mean that filename.txt on my server would be uploaded to the
    > webserver as filenameYYMMDDhhmmss.txt or something similar.
    > Can anyone advise how to do this?


    Most likely, depends on what upload component you are using. Several have a
    SaveAs method or something equivalent.

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)
    Aaron [SQL Server MVP], Sep 28, 2004
    #2
    1. Advertising

  3. Hello,

    If your file name 100% has file extension:

    Get file extension:
    Response.Write UBound (Split (LCase ("filename.com.txt"), ".", -1, 1))

    Get date/time stamp:
    N = Now
    Response.Write Right ("0" & Year (N), 4) & Right ("0" & Month (N), 2) &
    Right ("0" & Day (N), 2) & "_" & Right ("0" & Hour (N), 2) & Right ("0" &
    Minute (N), 2) & Right ("0" & Second(Now), 2)

    Or, simple rename file later, after upload. Do upload in some temporarely
    folder (by date/time), then rename file.

    With best regards,

    --

    Should you have any questions, please don't hesitate to contact me.
    If you response to an email, please quote the complete message.
    http://1click.lv

    "kbrad" <> wrote in message
    news:...
    > I am uploading files to my webserver using an asp upload script and would
    > like to add a timestamp just before they are saved to the server.
    > This would mean that filename.txt on my server would be uploaded to the
    > webserver as filenameYYMMDDhhmmss.txt or something similar.
    > Can anyone advise how to do this?
    Andrew Zamkovoy, Sep 28, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9l?=

    Extract filename from a filename typed by user

    =?Utf-8?B?Sm9l?=, Aug 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,002
    Travis Murray
    Aug 24, 2004
  2. Replies:
    1
    Views:
    1,431
    Roland de Ruiter
    Jun 15, 2006
  3. Ed
    Replies:
    10
    Views:
    45,726
    alok000707
    Jul 13, 2010
  4. Beauregard T. Shagnasty

    Re: filename.gif or filename.gif.jpg?

    Beauregard T. Shagnasty, May 30, 2008, in forum: HTML
    Replies:
    1
    Views:
    733
    Jonathan N. Little
    May 30, 2008
  5. Bergamot
    Replies:
    0
    Views:
    433
    Bergamot
    May 30, 2008
Loading...

Share This Page