Let's keep the same HTML form used in the previous example:
<HTML> <HEAD> <TITLE>Please Upload Your File</TITLE> </HEAD> <BODY> <form enctype="multipart/form-data" method="post" action="formresp.asp"> Enter filename to upload: <input type="file" name="f1"><br> <input type="submit"> </form> </BODY> </HTML>
Here's how we can preserve the user's original filename:
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>Upload File Results</TITLE>
</HEAD>
<BODY>
Thank you for uploading your file.<br>
<% Set upl = Server.CreateObject("SoftArtisans.FileUp") %>
<% upl.Path = "C:\temp" %>
<% upl.Save %><BR>
Total Bytes Written: <%=upl.TotalBytes%>
</BODY>
</HTML>
So, to preserve the user's original filename, we use the .Save method instead of .SaveAs. The .Save method automatically extracts the user's filename from the upload and saves the file on the server with that name.
The .Save method does not take any parameters. To set the location you must set the .Path property. The .Path property sets the directory on the web server to place uploaded files.
The directory on the web server must have Read, Write, and Delete
NTFS permissions. Otherwise,
![]() |
You can also use the .Path property in conjunction with the .SaveAs method: |
<% upl.Path = "C:\temp" %><BR>
<% upl.SaveAs "upload.out" '--- Change the name on the server but leave it in C:\temp %>Or, you can change the final destination before saving:
<% upl.Path = "C:\temp"
If Sky = "blue" Then
upl.Save
Else
upl.SaveAs "d:\OtherUploadDir\upload2.new"
End If
%>
Now, let's add Multiple Form Elements
| Previous Page | Next Page |