SaveInVirtual Method

Object: SoftArtisans.FileUp
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 .

When using the SaveInVirtual method of the FileUp object, if there is more than one file being uploaded in a single page, only the first one is saved.

To save multiple files in a single upload, there is an equivalent method for each file object, i.e., fileUpload.Form("File1").SaveInVirtual "filename". Please see SAFile.SaveInVirtual.

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.SaveInVirtual "./Uploads"
%>
C# fileUpload.SaveInVirtual("./Uploads");
VB.NET fileUpload.SaveInVirtual("./Uploads")

Specify a virtual directory that includes the file name:

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

Copyright © 2010 SoftArtisans, Inc. All rights reserved.