ServerName Property

Object: SoftArtisans.SAFile
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 file system.

Before a Save, SaveAs, or SaveAsBlob is executed, the ServerName property contains the location 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 you intend to only upload one file, your code may be made more brief using the ServerName property of the FileUp object. Please see: SAFileUp.ServerName

Examples:

Use the ServerName property to report back the name and path of the file as it was finally saved on the server. In this example, the resulting ServerName will be 'C:\Temp\upload.tst'.

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.Form("File1").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.Form("File1").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.Form["File1"].ServerName + "<br />");

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

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

results.Append("Upload saved successfully to: " +
((SaFile)fileUpload.Form["File1"]).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.Form("File1").ServerName + "<br />")

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

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

results.Append("Upload saved successfully to: " + _
CType(fileUpload.Form("File1"), SaFile).ServerName)

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

Copyright © 2010 SoftArtisans, Inc. All rights reserved.