AspUpload Sample Code

AspUpload is a COM+ component which enables an ASP application to capture, save and process files uploaded to the web server with a browser. The files are selected for uploading via an HTML POST form using the <INPUT TYPE=FILE> tag.

With AspUpload, you can add file upload functionality to your Web application in as little as 2 lines of ASP script. In addition to uploading, AspUpload offers a wide range of file management functions, including secure downloading, saving files in the database, permission and attribute management, image size extraction, file encryption, etc.


The following HTML form (located in the sample file Form1.asp) enables a user to select up to three files for uploading to the server:


   <FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="UploadScript1.asp">  

Notice the ENCTYPE="multipart/form-data" attribute in the <FORM> tag. It instructs the browser to send the entire file to the server and not just the file name entered in the input text box. It is absolutely mandatory that your upload forms contain this attribute, or no uploading can be performed.

This form contains three items <INPUT TYPE="FILE"> which appear on the page as text boxes with the Browse button next to them. Each box can be used to select one file only. While the SIZE attribute of an <INPUT TYPE="FILE"> item is optional, the NAME attribute is required.

This form invokes the upload script UploadScript1.asp shown below:


Set Upload = Server.CreateObject("Persits.Upload")  
Count = Upload.Save("c:\upload")   
Response.Write Count & " file(s) uploaded to c:\upload"