Knowledgebase: ASP programming

#A Simple Upload Form:
The following HTML form 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"
The first line of the ASP script simply creates an instance of the AspUpload object. The second line calls the Save method of the component which actually performs the upload: it parses the information POSTed by the browser, figures out how many files are being uploaded, and saves them in a specified local directory on the server under their original names.
The Save method returns the number of files successfully uploaded. In case of an error this method will throw an exception.

Article ID: 3, Created On: 4/19/2013, Modified: 4/19/2013

Feedback (0)