Forum Moderators: open

Message Too Old, No Replies

ASP Question

         

kevinj

6:45 pm on Feb 12, 2003 (gmt 0)

10+ Year Member



I have set up a browse upload function and my advertisers are able to upload their files to my server via a password protected system. I'm also writing the file name to my Access database. My question is how to parse the file name. Currently the whole path from their hard drive gets written to my database. I only want to write the file name (after the last "/") to the database. How can I do this?

Thanks.

korkus2000

7:41 pm on Feb 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What language are you using VB, Jscript?

kevinj

7:53 pm on Feb 12, 2003 (gmt 0)

10+ Year Member



I'm using VBscript

RZaakir

8:26 pm on Feb 12, 2003 (gmt 0)

10+ Year Member



Just take the path and use the InStrRev VBScript function to determine where the first (i.e. last) occurence of a backslash is.

Something like this (off the top of my head, there may be some syntax anomalys):

FullPathname = "C:\dir1\dir2\file.ext"
Filename = Right(FullPathname, (Len(FullPathname) - InStrRev(FullPathname, "\")))

In your code, FullPathname would be whatever variable you have that holds the full file path. The Filename variable would be the actual file name that goes into your database. You could actually do it in one line of code if you substiture FullPathname with your full path.

kevinj

9:23 pm on Feb 12, 2003 (gmt 0)

10+ Year Member



Works perfect RZaakir! Thanks.

RZaakir

1:33 am on Feb 13, 2003 (gmt 0)

10+ Year Member



My pleasure Kevin...