This example shows how to upload a file to a file server preserving any Macintosh or Unicode attributes of the original file. It assumes that minimal configuration settings in the web.config file are implemented.

 

   
HTML
 
sfmupload.htm    
     

Our multipart HTML form contains one file field for upload. This page then submits data to sfmupload.aspx.

<html>
<body>
<form method="post" action="sfmupload.aspx" enctype="multipart/form-data">
<input type="file" name="file"><br>
<input type="submit" name="submit" value="submit">
</form>
<body>
</html>


   
ASP
 
sfmupload.aspx    
     

We create an Upload object, and if a file has been uploaded, save it to a location. ABCUpload will automatically detect that we're specifying the destination location using a URL and will place the file appropriately. Here we use the WinSafeFileName to name the file - this is a Windows safe version of the original file name in Unicode format.

If the file came from a Macintosh the WinSafeFileName will contain the name of the file converted into the format used by Services for Macintosh (SFM). If the file was uploaded by Internet Explorer and is saved to a SFM volume Macintosh users will see a file identical to the original uploaded file with both resource and data forks intact.

[C#]
<%@ Import Namespace="WebSupergoo.ABCUpload6" %>

<html>
<body>
<%

Upload theUpload = new Upload();
UploadedFile theFile = theUpload.Files["file"];

if (theFile.Exists) {
  theFile.SaveSFM("write/" + theFile.WinSafeFileName);
  Response.Write("File uploaded...");
}
else {
  Response.Write("No file uploaded...");
}

%>
</body>
</html>

[VB]
<%@ Import Namespace="WebSupergoo.ABCUpload6" %>

<html>
<body>
<%

Dim theUpload As Upload = New Upload()
Dim theFile As UploadedFile = theUpload.Files("file")

If theFile.Exists = True Then
  theFile.SaveSFM("write/" + theFile.WinSafeFileName)
  Response.Write("File uploaded...")
Else
  Response.Write("No file uploaded...")
End If

%>
</body>
</html>