NetVIOS Upload Component in Webfaces
Uses: uploades files from local computer to website over a web page on the site.
Cost: Free
Version: 1.1
Platforms: Windows NT, Windows 2000, Windows 2003 servers.
Additional Features
- Restricts uploads by file type (a remote upload procedure is not too useful if it does not contain means to restrict uploads by file types)
- Allows other form elements to be submitted with uploaded file and retrieves their values
Properties
Input
FileUploadControl - name of the File html GUI control of type = FILE
SavePath - path on the web server in which file will be saved
MaximumSize - limit of file size that is allowed to be uploaded
OverWriteFiles - indicator to determine if file should be uploaded if a file already exists with the same name.
Output
GetFileCount - Number of files uploaded
GetFileName(i) - Name of ith file uploaded
GetFileSize(i) - Size of ith file uploaded
Methods
Upload - performs the upload and sets the output properties (above).
Sample Code
You may use a text editor to complete this example of using the upload component. This example requires two files - one that promptes the user for the local file to upload (upload.html) and a second that uses the component to perform the upload (_upload.asp). (Note that these two files may be combined but is separated for easier illustration).
First File
Create an html page with the upload GUI control (save as upload.html for example). The html page will have content as shown below:
<html><body>
<form name="uploadform" enctype="multipart/form-data" action="_upload.asp" method="post" >
<p><input TYPE="FILE" NAME="File1" SIZE="50"><br>
<input TYPE="SUBMIT" VALUE="Upload File!"> </p>
</form>
</body></html>
Second File
Create an asp page that uses the component to perform the upload (save as _upload.asp for example). The contents will be as shown below:
<%
'Initialize the component
Set myup = Server.CreateObject("ubvios.Upload")
'Set the name of the GUI control used in acquiring the file (from the first file)
myup.FileUploadControl = "File1"
'Set the path on the web server in which file is to be saved
myup.SavePath = "E:\Sites\NetVIOS"
'Set the maximum allowable file size in bytes
myup.MaximumSize = 5000000
'Set the overwrite property
myup.OverwriteFiles = True
'Perform the upload
upresult = myup.Upload()
If (upresult = "Success") Then
'Print an optional report of files downloaded
For iup = 1 To myup.GetFileCount
Response.Write "The file - " & myup.GetFileName(iup) & " of size " & myup.GetFileSize(iup)
Response.Write " was successfully uploaded!"
Next
End If
'Destroy the upload component instance after use
Set myup = Nothing
%>
(Note that the colors above are used for illustration purposes only)
Notes
Ensure that the specification - enctype="multipart/form-data" - is present in the description of the upload form in the html file.
Advanced Properties
SetFileName(i) - changes the filename of the uploaded file to the value of this property (input property).
PostedData - retrieves the exact posted data
FileType - allows upload of a specific file types. The file types may be entered as a list of extensions separated by commas. Also accepts groups of file types. Accepted group types include:
- Image - .gif, .jpg, .jpeg, .bmp, .png, .wmf
- Media - .avi, .mov, .mpg, .wav, .au, .wme, .wmx, .wma, .wmv
- Text - .txt, .text
- Html - .htm, .html
- Excel - .xls, .csv
- Doc - .doc, .rtf
- Pdf - .pdf
- Alltypes - all the above types (default value)
- Anytype - allows upload of any file (user beware)
Example
If the code lines below are inserted before the Upload method is called in the first example above, only files with the extensions indicated above will be uploaded.
<%
'Allows only image files to be uploaded
myup.FileType = "Image"
'Allows only files with extension .gif and .txt to be uploaded
myup.FileType = "gif,txt"
%>
Notes
Property is not case sensitive.
If ommitted, the default is to allow the uploading of all file types!
ControlName(i) - name of an additional control or form item submitted with the form data (input property). Only 10 additional form items allowd in the current version.
ControlValue(i) - value of the submitted form data (output property). This property can only be retrieved after the Upload method has been called.
Examples
View examples of usage here http://webfacesite.netvios.com/. In each example, there is an active file (.asp), and a view file (.htm) that shows the script contents of the active file.
Notes on Webfaces
You may alternatively use the Webface elements - UploadFile, UploadPick, UploadUnique instead of constructing your own Upload scripts. For details, check the Webfaces manual.
Report bugs, installation problems or questions or simply leave positive feedback here.
NetVIOS Webfaces
Other Products
Other Components