Persits Upload  component

In this example we will upload files from our computer to our remote server, so we will need a form to send the files ("Uploadfiles.html") and a response page which will save those files in our remote server ("Uploadfiles.asp").

An example of a form we may use to send the files is provided bellow ("Uploadfiles.html"). In this example three input fields are included so that we will be able to upload up to three files simultaneously. The form must use POST method, and specific value for "ENCTYPE" is defined to allow transmission of files. This form will point to the response page ("Uploadfiles.asp").
 

Uploadfiles.html
<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="Uploadfiles.asp">
<INPUT TYPE="FILE" SIZE="40" NAME="FILE1"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE2"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE3"><BR>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>

The code we will need to include in our response page is very sort:
 

Uploadfiles.asp
<%
Wfolder="/cgi-bin"
Set Upload = Server.CreateObject("Persits.Upload.1")
NumberOfFiles= Upload.SaveVirtual(Wfolder)
Response.Write (NumberOfFiles & " files saved to folder " & Wfolder)
%> 
Line 2 - we will define the folder where the files will be saved (variable Wfolder),
Line 3 - the corresponding object is create
Line 4 - the files are saved to the server
Line 5 - the response message is send back to user
NOTES:
    Wfolder="" will save the files to main folder.
    Wfolder="/cgi-bin" is correct,
    Wfolder="/cgi-bin" is not correct
    You will get an error when trying to upload files to folders without writing permission

AspTutorial.info.