To extract the filename as the file was saved to the server, string parsing functions may be applied to the value returned by the ServerName property. This may be useful if the name of the file is expected to be changed before it is saved, such as with the CreateNewFile property of the FileUp object. The following sample demonstrates how the server-side filename can be determined.
'--- Instantiate the FileUp object
Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
'--- Set the Path property to the location you wish to
'--- temporarily cache the incoming file before saving
'--- Note: This property must be set immediately after
'--- instantiating the FileUp object
oFileUp.Path = "C:\SaveHere"
'--- Instruct FileUp to generate a unique file name if the
'--- file's original name already exists on the server.
'--- Important: Set CreateNewFile before referencing form elements.
oFileUp.CreateNewFile = True
'--- Check to be sure there was a file selected in the form
'--- If so, continue processing
If Not oFileUp.Form("myFile").IsEmpty Then
'--- Save the file
'--- The ServerName() property is the full path of the file
'--- where it was saved on the server
strServerName = oFileUp.Form("myFile").ServerName
'---Extract the filename from the complete path
strFileName = Mid(strServerName, InstrRev(strServerName, "\")
'--- The file is saved, display a confirmation message
Response.Write("<B>File saved successfully
on the server as: " & _
strFileName & "</B><BR>")
("Error: There was no file submitted for upload.")
'--- Destroy objects
Set oFileUp = Nothing