ASP Upload Component is ActiveX component designed to ease access to multipart/form-data received from client's browser when developing Active Server Pages applications. With this component installed you can access multible file uploads and other form data just the way it is done with Request object.
OS:
Web Server:
After receiving archive with ASP Upload component:
Download Windows Installer if during the installation process you receive following message:
The loader can not find the 'D:\path\to\setup\files\InstMsiW.exe' file necessary to load the Windows Installer.
For file uploads to be posted properly there are three required attribute settings for sender form:
Other form attributes are not relevant to component functionality. Each form may contain all types of controls in any combinations.
<form method="post" enctype="multipart/form-data" action="demo.asp" name="test_form"> Specify the File: <input type="File" name="file_upload1"><br> Save As: <input type="Text" name="new_filename1"><br> Specify the File: <input type="File" name="file_upload2"><br> Save As: <input type="Text" name="new_filename2"><br> Allow Overwrite: <input type="Checkbox" name="allow_overwrite"><br> <input type="Submit" name="Submit" value="Upload!"> </form>
Note: Component can also process form posts without any file uploads. In such case form attribute enctype is not required.
PostStream Object allows access to fields and files posted by HTML form. Poststream object parses data posted by HTML form and presents it to the ASP script as enumerable collection.
VBasic:
Set NewPostStreamObject = Server.CreateObject("SoftComplex.ASP.PostStream")
Jscript:
var NewPostStreamObject = Server.CreateObject("SoftComplex.ASP.PostStream");
boolean PostStreamObject.Empty
boolean PostStreamObject.Buffer
boolean PostStreamObject.EOF
int PostStreamObject.Count
int PostStreamObject.Limit
FormItem | FileItem PostStreamObject.Current
boolean PostStreamObject.MoveNext()
FormItem | FileItem PostStreamObject.Item (int index | string name)
FormItem | FileItem PostStreamObject (int index | string name)
FormItem Object represents text based HTML form element (types: Text, Password, Checkbox, Hidden etc.) posted by HTML form.
VBasic:
Set NewFormItemObject = PostStreamObject.Item(int index | string name) Set NewFormItemObject = PostStreamObject(int index | string name)
Jscript:
var NewFormItemObject = PostStreamObject.Item(int index | string name); var NewFormItemObject = PostStreamObject(int index | string name);
string FormItemObject.Name
string FormItemObject.Value
boolean FormItemObject.File
boolean FormItemObject.Empty
FormItem Object represents file upload posted with HTML form.
VBasic:
Set NewFileItemObject = PostStreamObject.Item(int index | string name) Set NewFileItemObject = PostStreamObject(int index | string name)
Jscript:
var NewFileItemObject = PostStreamObject.Item(int index | string name); var NewFileItemObject = PostStreamObject(int index | string name);
string FileItemObject.Name
string FileItemObject.Value
boolean FileItemObject.File
boolean FileItemObject.Empty
boolean FileItemObject.FileName
FileItemObject.Save(string dir_path | string file_path)
FileItemObject.SaveEx(string dir_path | string file_path, boolean overwrite)
Code below demonstrates VBasic usage of ASP upload component for single file upload in buffered mode. This script also shows how to handle errors when using component.
<%@Language=VBScript%> <html> <body> <!-- All forms that send files should have attributes set: method="post" enctype="multipart/form-data" --> <form method="post" enctype="multipart/form-data"> <input name="file" type="file"><br> <input type="submit"> </form> <br> <% ' enable error handling On Error Resume Next ' create instance of ASP Upload Component Set PostStream = Server.CreateObject("SoftComplex.ASP.PostStream") ' ensure that the component instantiated successfully If Err.Number <> 0 Then ' report error if instantiation failed ReportError "Can't create ""ASP Upload Component"" component." ' check if any data is available (there is no data when form called with get method) ElseIf PostStream.Empty Then ' print welcome message on form's first load Response.Write "Select a file and press ""Submit"" in order to upload it" Else ' check if file submitted contains any data FileIsEmpty = PostStream("file").Empty If Err.Number <> 0 Then ' transfer unhandled errors - with trial version "Stream limit excided" error ReportError "" ElseIf FileIsEmpty Then ' report empty file submission ReportError "You have submitted an empty file." Else ' save file on the local drive in the directory of your choice ("uploads") with it's original name PostStream("file").Save("uploads") If Err.Number <> 0 Then ' report error if any ReportError "Can't save uploaded file." Else ' report success Response.Write "File """ & PostStream("file").FileName & """ has been successfully uploaded and saved." End If End If End If 'Just a simple function to report errors Function ReportError(message) Response.Write "<font color=""red""><b>" If message <> "" Then Response.Write message & "<br>" End If If Err.Number <> 0 Then Response.Write "Error: " & Err.Description End If Response.Write "</b></font>" Err.Clear End Function %> </body> </html>
Code below demonstrates VBasic usage of ASP upload component for multiple file upload in buffered mode. This script also shows how to handle errors when using component.
<%@Language=VBScript%> <html> <body> <!-- All forms that send files should have attributes set: method="post" enctype="multipart/form-data" --> <form method="post" enctype="multipart/form-data"> <input name="file1" type="file"><br> <input name="file2" type="file"><br> <input name="file3" type="file"><br> <input name="file4" type="file"><br> <input type="submit"> </form> <br> <% ' enable error handling On Error Resume Next ' create instance of ASP Upload Component Set PostStream = Server.CreateObject("SoftComplex.ASP.PostStream") ' ensure that the component instantiated successfully If Err.Number <> 0 Then ' report error if instantiation failed ReportError "Can't create ""ASP Upload Component"" component." ' check if any data is available (there is no data when form called with get method) ElseIf PostStream.Empty Then ' print welcome message on form's first load Response.Write "Select a file and press ""Submit"" in order to upload it" Else Do ' obtain the next file filed Set file = PostStream.Current If Err.Number <> 0 Then ' transfer unhandled errors - with trial version "Stream limit excided" error ReportError "" Exit Do ElseIf file.Empty Then ' report empty file submission If file.FileName <> "" Then ReportError file.FileName & " is empty." Else ReportError "Form field """ & file.Name & """ is not filled." End If Else ' save file on the local drive in the directory of your choice ("uploads") with it's original name file.Save("uploads") If Err.Number <> 0 Then ' report error if any ReportError "Can't save """ & file.FileName & """." Else ' report success Response.Write "File """ & file.FileName & """ has been successfully uploaded and saved." End If End If Response.Write "<br>" ' move to the next field until end Loop While PostStream.MoveNext End If 'Just a simple function to report errors Function ReportError(message) Response.Write "<font color=""red""><b>" If message <> "" Then Response.Write message End If If Err.Number <> 0 Then If message <> "" Then Response.Write "<br>" End If Response.Write "Error: " & Err.Description End If Response.Write "</b></font>" Err.Clear End Function %> </body> </html>
Code below demonstrates VBasic usage of ASP upload component for multiple files upload together with text based fields submission in buffered mode. This script also shows how to handle errors when using component.
<%@Language=VBScript%> <html> <body> <i>* file name to save file as / overwrite flag / file to upload </i> <!-- All forms that send files should have attributes set: method="post" enctype="multipart/form-data" --> <form method="post" enctype="multipart/form-data"> <input name="saveas1" type="text"> <input type="checkbox" name="overwrite1"> <input name="file1" type="file"><br> <input name="saveas2" type="text"> <input type="checkbox" name="overwrite2"> <input name="file2" type="file"><br> <input name="saveas3" type="text"> <input type="checkbox" name="overwrite3"> <input name="file3" type="file"><br> <input name="saveas4" type="text"> <input type="checkbox" name="overwrite4"> <input name="file4" type="file"><br> <input type="submit"> </form> <br> <% ' enable error handling On Error Resume Next ' create instance of ASP Upload Component Set PostStream = Server.CreateObject("SoftComplex.ASP.PostStream") ' ensure that the component instantiated successfully If Err.Number <> 0 Then ' report error if instantiation failed ReportError "Can't create ""ASP Upload Component"" component." ' check if any data is available (there is no data when form called with get method) ElseIf PostStream.Empty Then ' print welcome message on form's first load Response.Write "Select a file and press ""Submit"" in order to upload it" Else For index=1 to 4 ' obtain the file filed Set file = PostStream("file" & index) If Err.Number <> 0 Then ' transfer unhandled errors - with trial version "Stream limit excided" error ReportError "" Exit For End If ' obtain the "save as" filed value saveAs = PostStream("saveas" & index) ' obtain the "overwrite" filed value overwrite = PostStream("overwrite" & index) If file.Empty Then ' report empty file submission If file.FileName <> "" Then ReportError file.FileName & " is empty." Else ReportError "Form field """ & file.Name & """ is not filled." End If Else ' save file on the local drive in the directory of your choice ("uploads") with it's original name file.SaveEx "uploads/" & saveAs, overwrite = "on" If Err.Number <> 0 Then ' report error if any ReportError "Can't save """ & file.FileName & """." Else ' report success Response.Write "File """ & file.FileName & """ has been successfully uploaded and saved" If saveAs <> "" Then Response.Write " as """ & saveAs & """." Else Response.Write "." End If End If End If Response.Write "<br>" ' move to the next field until end Next End If 'Just a simple function to report errors Function ReportError(message) Response.Write "<font color=""red""><b>" If message <> "" Then Response.Write message End If If Err.Number <> 0 Then If message <> "" Then Response.Write "<br>" End If Response.Write "Error: " & Err.Description End If Response.Write "</b></font>" Err.Clear End Function %> </body> </html>
Code below demonstrates VBasic usage of ASP upload component for multiple files upload together with text based fields submission in unbuffered mode. This script also shows how to handle errors when using component.
<%@Language=VBScript%> <html> <body> <i>* file name to save file as / overwrite flag / file to upload </i> <!-- All forms that send files should have attributes set: method="post" enctype="multipart/form-data" --> <form method="post" enctype="multipart/form-data"> <input name="saveas1" type="text"> <input type="checkbox" name="overwrite1"> <input name="file1" type="file" ID="File1"><br> <input name="saveas2" type="text"> <input type="checkbox" name="overwrite2"> <input name="file2" type="file" ID="File2"><br> <input name="saveas3" type="text"> <input type="checkbox" name="overwrite3"> <input name="file3" type="file" ID="File3"><br> <input name="saveas4" type="text"> <input type="checkbox" name="overwrite4"> <input name="file4" type="file" ID="File4"><br> <input type="submit"> </form> <br> <% ' enable error handling On Error Resume Next ' create instance of ASP Upload Component Set PostStream = Server.CreateObject("SoftComplex.ASP.PostStream") ' turn off buffering in order to minimize system resources usage (by default it's turned on) PostStream.Buffer = false ' ensure that the component instantiated successfully If Err.Number <> 0 Then ' report error if instantiation failed ReportError "Can't create ""ASP Upload Component"" component." ' check if any data is available (there is no data when form called with get method) ElseIf PostStream.Empty Then ' print welcome message on form's first load Response.Write "Select a file and press ""Submit"" in order to upload it" Else Do Dim saveAs, overwrite, file ' obtain the "save as" filed value saveAs = PostStream.Current ' obtain the "overwrite" filed value PostStream.MoveNext ' obtain the file filed If PostStream.Current.File Then Set file = PostStream.Current overwrite = "off" Else overwrite = PostStream.Current PostStream.MoveNext Set file = PostStream.Current End If If Err.Number <> 0 Then ' transfer unhandled errors - with trial version "Stream limit excided" error ReportError "" Exit Do End If If file.Empty Then ' report empty file submission If file.FileName <> "" Then ReportError file.FileName & " is empty." Else ReportError "Form field """ & file.Name & """ is not filled." End If Else ' save file on the local drive in the directory of your choice ("uploads") with it's original name file.SaveEx "uploads/" & saveAs, overwrite = "on" If Err.Number <> 0 Then ' report error if any ReportError "Can't save """ & file.FileName & """." Else ' report success Response.Write "File """ & file.FileName & """ has been successfully uploaded and saved" If saveAs <> "" Then Response.Write " as """ & saveAs & """." Else Response.Write "." End If End If End If Response.Write "<br>" ' move to the next field until end Loop While PostStream.MoveNext End If 'Just a simple function to report errors Function ReportError(message) Response.Write "<font color=""red""><b>" If message <> "" Then Response.Write message End If If Err.Number <> 0 Then If message <> "" Then Response.Write "<br>" End If Response.Write "Error: " & Err.Description End If Response.Write "</b></font>" Err.Clear End Function %> </body> </html>
One single server ASP Upload Component license gives the right to use one installation of the component. Component can be used by unlimited number of sites/domains hosted on the server.
One single organization ASP Upload Component license gives the right to use unlimited installations of the component within single organization network.
Developer license gives the right to include unlimited number of ASP Upload Component instances in the products of license owner. Such kind of license is obtained automatically by those who has 5 or more single licenses of any type above.
After license order customers are offered special (significantly discounted) prices for other products of SoftComplex.
As owner of the ASP Upload Component license You are allowed to use the component in any possible way in Internet (public), Intranet (corporate), however You are strictly NOT allowed (unless specifically authorized by SoftComplex.com) to:
You are entitled to free product upgrades and technical support for at least one year from the date of purchase. Technical support includes answers to script related questions via via e-mail and/or Internet instant messaging services.
Should you violate these Terms and Conditions or any other rights of SoftComplex Inc., SoftComplex Inc. reserves the right to pursue any and all legal and equitable remedies against you without limitation.