ServerName Property

Object: SoftArtisans.FileUp
Syntax: ServerName
Type: String
Read/Write: Read Only
Description:

This property displays the complete path and name of the uploaded file on the web server's hard disk.

Before a Save, SaveAs or SaveAsBlob is executed, the ServerName property contains the location and name of the temporary cache file used when processing uploads. After a Save, SaveAs or SaveAsBlob, ServerName displays the complete path and name of the final location of the file.

The cache filename is always guaranteed to be unique. You can use the .ServerName property to generate a unique name when saving the file. The cache file's name is of the form saNNNN.tmp, where NNNN is a unique number. See Example 2, below.

If there is more than one file being uploaded in a single page, only the first one is displayed.

To examine the Server Name of multiple files in a single upload, there is an equivalent property for each file object, i.e., fileUpload.FormEx("FILE1").ServerName. Please see SAFile.ServerName

Examples:
ASP <%
'--- Instantiate FileUp
Set fileUpload = Server.CreateObject("SoftArtisans.FileUp")

'--- Set cache/default save location
fileUpload.Path = "C:\Temp"
filename = "upload.tst"
Response.Write("The uploaded file is now cached in: " & _
fileUpload.ServerName & "<br />")

Response.Write("Saving the file to: " & filename & "<br />")

On Error Resume Next

'--- Save upload
fileUpload.SaveAs filename

If Err = 0 Then
Response.Write("Upload saved successfully to: " & _
fileUpload.ServerName)
Else
'--- Handle errors
End If
%>

ServerName will display "C:\Temp\upload.tst"

C# //--- Instantiate FileUp
FileUp fileUpload = new FileUp(Context);

//--- Set cache/default save location
fileUpload.Path = @"C:\Temp";
filename = "upload.tst";

results.Append("The uploaded file is now cached in: " +
fileUpload.ServerName + "<br />");

results.Append("Saving the file to: " + filename + "<br />");

//--- Save upload
fileUpload.SaveAs(filename);

results.Append("Upload saved successfully to: " +
fileUpload.ServerName);

ServerName will display "C:\Temp\upload.tst"

VB.NET '--- Instantiate FileUp
Dim fileUpload As New FileUp(Context)

'--- Set cache/default save location
fileUpload.Path = "C:\Temp"
filename = "upload.tst"

results.Append("The uploaded file is now cached in: " + _
fileUpload.ServerName + "<br />")

results.Append("Saving the file to: " + filename + "<br />")

'--- Save upload
fileUpload.SaveAs(filename)

results.Append("Upload saved successfully to: " + _
fileUpload.ServerName)

ServerName will display "C:\Temp\upload.tst"

Copyright © 2010 SoftArtisans, Inc. All rights reserved.