Print Page | Close Window

submit file name in a form?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6788
Printed Date: 31 March 2026 at 4:31pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: submit file name in a form?
Posted By: zMaestro
Subject: submit file name in a form?
Date Posted: 28 October 2003 at 1:53pm

sorry, i think this question was asked many times before, i want to just trim the name of the file from a form, i.e. when the user enters:
C:\Documents and Settings\ashrafvision\Desktop\5124.jpg
just the value 5124.jpg enter the database

how can i remove the C:\Documents and Settings\ashrafvision\Desktop\

sorry again, and thanks.




Replies:
Posted By: fernan82
Date Posted: 28 October 2003 at 2:56pm
There might be an easier way but something like this will do it:

Dim intPos
intPos = 1

Do While inStr(intPos, strFilename, "\", 1)
   intPos = inStr(intPos, strFilename, "\", 1) + 1
Loop

strFilename = Right(strFilename, Len(strFilename) - (intPos - 1))

Might have to do some tweaking to get it to work right but that's an idea...

-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Flamewave
Date Posted: 29 October 2003 at 10:10am

filename = StrReverse(filename)
filename = Left(filename, (Len(filename) - InStr(filename, "/"))
filename = StrReverse(filename)

something along those lines should work to. You may need to tweak it a bit as I didnt test it out to be sure it worked. You could also use a regular expression replace statement if you know enugh about regular expresions (I don't, otherwise I would have posted that).



-------------
- Flamewave

They say the grass is greener on the other side, but if you really think about it, the grass is greener on both sides.


Posted By: MorningZ
Date Posted: 29 October 2003 at 10:53am

One line of code:

fileName = Mid(fileName, InstrRev(fileName,"\")+1)

 



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: zMaestro
Date Posted: 29 October 2003 at 11:58am
Originally posted by MorningZ MorningZ wrote:

One line of code:

fileName = Mid(fileName, InstrRev(fileName,"\")+1)

worked perfectly




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net