Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 68
Product
FileUp
Version
2.x, 3.x
Title
HOWTO: Extract just the filename or extension of an uploaded file
Problem
At times, you will likely want to obtain just the filename or extension of an uploaded file using FileUp.
Solution
Using FileUp v3.31 and below, you will have to parse out the filename from the UserFileName property. UserFileName returns the full path and filename string from the client machine for an uploaded file.

Here's how to obtain just the filename from that string:

strFilename = Mid(oFileUp.UserFilename, InstrRev(oFileUp.UserFilename, "\") + 1)


For just the extension, use:

strExtension = Mid(oFileUp.UserFilename, InstrRev(oFileUp.UserFilename, ".") + 1)

In FileUp v3.32 and above, you can use the ShortFileName property instead. This property returns the user's original filename without path information, without the need for special parsing of the UserFileName property:

strFileName = oFileUp.ShortFileName

Note: If you have multiple file fields in your form, you will need to refer to them explicitly like this:

oFileUp.Form("fieldname").UserFileName

or
oFileUp.Form("fieldname").ShortFileName
Created : 12/1/2002 12:00:00 AM (last modified : 7/16/2003 12:18:50 PM)
Rate this article!
Comments