Customer Portal Language
 
HomeKnowledge BaseHostingaspSmartUpload Example Usage
Information
Article ID276
Created On1/23/2009
Modified2/9/2009
aspSmartUpload Example Usage

Form

The ENCTYPE="multipart/form-data" attribute in the FORM tag is required.

Example :

<FORM ENCTYPE="multipart/form-data" ACTION="/scripts/aspSmartUpload/upload.asp">
<INPUT TYPE="FILE" NAME="MYFILE">
<INPUT TYPE="SUBMIT">
</FORM>


Request

For an Upload the ASP "Request" object can not be used to retrieve form fields. But it is possible to use the "Request" object to retrieve parameters used in an URL.

Example :

HTML Form

<HTML>
<BODY>
    <FORM ENCTYPE="multipart/form-data" ACTION="/scripts/aspSmartUpload/upload.asp?MYPARAM=test">
    <INPUT TYPE="TEXT" NAME="MYTEXT">
    <INPUT TYPE="FILE" NAME="MYFILE">
    <INPUT TYPE="SUBMIT">
    </FORM>
</BODY>
<HTML>


ASP Script

<%

' Impossible
' ********
' Request("MYPARAM")
' Request("MYTEXT")
' Request("MYFILE")

' Possible
' ******
Request.QueryString("MYPARAM")
Set myUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
myUpload.Upload
myUpload.Form("MYTEXT")
myUpload.Files("MYFILE")

%>


Upload method

The Upload method must be called before any other methods of the aspSmartUpload object.

Example :

<%
Set myUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

' Impossible
' ********
' myUpload.Form("MYTEXT")
' myUpload.Upload

' Possible
' ******
myUpload.Upload
myUpload.Form("MYTEXT")
%>


Code Behind Example

<%
'  Variables
'  *********
   Dim mySmartUpload
   Dim intCount
       
'  Object creation
'  ***************
   Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")

'  Upload
'  ******
   mySmartUpload.Upload

'  Save the files with their original names in a virtual path of the web server
'  ****************************************************************************
   intCount = mySmartUpload.Save("/aspSmartUpload/Upload")
   ' sample with a physical path
   ' intCount = mySmartUpload.Save("c:\temp\")

'  Display the number of files uploaded
'  ************************************
   Response.Write(intCount & " file(s) uploaded.")
%>