SaveInVirtual Method

Object: SoftArtisans.SAFile
Syntax: SaveInVirtual([in] VirtualLocation As String)
Description:

This method saves an uploaded file to the web server's hard disk in a location specified by the virtual directory or filename in a virtual directory.

SaveInVirtual uses the ASP or ASP.NET Server.MapPath() function internally. The virtual directory is then mapped to a physical directory for FileUp to use. You must be certain that the physical directory to which the virtual path maps, has the correct NTFS permissions to save the file. For more information on these permissions, please see the "Configuration and Application Planning" section this documentation set and read the permissions topics that apply to the language and configuration that you are using. As with the MapPath function, you specify either a virtual directory or a filename. If you specify a filename, it is resolved in the current virtual directory.

The Web Administrator can disable all other save methods except SaveInVirtual. This prevents the Web Developer from writing to non-virtual directory locations on the server. See Disabling FileUpfeatures .

If the upload destination folder is a virtual directory, a malicious user may be able to upload an infected file to the directory and launch it through the Web. To prevent this, use a folder that is not a virtual directory as the upload destination location.
Examples:

Specify a virtual directory, but keep the user's original filename:

ASP <%
fileUpload.Form("File1").SaveInVirtual "./Uploads"
%>
C# fileUpload.Form["File1"].SaveInVirtual("./Uploads");
VB.NET fileUpload.Form("File1").SaveInVirtual("./Uploads")

Specify a virtual directory that includes the file name:

ASP <%
fileUpload.Form("File1").SaveInVirtual "./Uploads/Myfile.ext"
%>
C# fileUpload.Form["File1"].SaveInVirtual("./Uploads/Myfile.ext");
VB.NET fileUpload.Form("File1").SaveInVirtual("./Uploads/Myfile.ext")

Copyright © 2010 SoftArtisans, Inc. All rights reserved.