UploadedFile


The UploadedFile class holds the information about the uploaded file. It contains the original names, paths, size and contents of all the files uploaded. This class can be accessed  by calling the 'UploadedFile' method on Upload  object.




 METHODS:



 PROPERTIES:




DESCRIPTION OF METHODS


Method Signature:   void copy([in]String   fullyQualifiedPath, [Optional] boolean overwrite)

This method copies the uploaded file to the another path as specified by the fully qualified path name in the argument.  Overwriting is by default True, but if overwrite is False, and the file with this name alredy exists, then this methods fails.

Example:
(for copying files)

Html page:

         <HTML>  <HEAD>
        <TITLE>Multiple File Upload via iASP_Upload</TITLE>
        </HEAD>
        <BODY>
        <form enctype="multipart/form-data" method="post" action="sample2.asp">
        Enter filename to upload: <input type="file" name="file1"><br>
        Enter filename to upload: <input type="file" name="file2"><br>
        Enter filename to upload: <input type="file" name="file3"><br>
        <input type="submit">
        </form>
        </BODY>
        </HTML>

Script of 'sample2.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"
        For Each File in obj.Files
        File.copy "d:\archive\" &  File.extractFileName, false
        Next
        %>



Method Signature:   void copyVirtual([in]String   VirtualDir, [Optional] boolean overwrite)

This method copies the uploaded file to the virtual directory as specified by the fully qualified path in the argument.  Overwriting is by default True, but if overwrite is False, and the file with this name alredy exists, then this methods fails.

Example:
(for copying files in virtual directory)

Html page:

         <HTML>  <HEAD>
        <TITLE>Multiple File Upload via iASP_Upload</TITLE>
        </HEAD>
        <BODY>
        <form enctype="multipart/form-data" method="post" action="sample2.asp">
        Enter filename to upload: <input type="file" name="file1"><br>
        Enter filename to upload: <input type="file" name="file2"><br>
        Enter filename to upload: <input type="file" name="file3"><br>
        <input type="submit">
        </form>
        </BODY>
        </HTML>

Script of 'sample2.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"
        For Each File in obj.Files
        File.copyVirtual "d:\virDir\" &  File.extractFileName, false
        Next
        %>




Method Signature:   void move([in]String   dirName)

This method moves the uploaded file to the another folder on the server as specified in the argument.

Example:
(for moving files)

Html page:

         <HTML>  <HEAD>
        <TITLE>Multiple File Upload via iASP_Upload</TITLE>
        </HEAD>
        <BODY>
        <form enctype="multipart/form-data" method="post" action="sample2.asp">
        Enter filename to upload: <input type="file" name="file1"><br>
        Enter filename to upload: <input type="file" name="file2"><br>
        Enter filename to upload: <input type="file" name="file3"><br>
        <input type="submit">
        </form>
        </BODY>
        </HTML>

Script of 'sample2.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"
        For Each File in obj.Files
        File.move "d:\temp2\" &  File.extractFileName
        Next
        %>



Method Signature:   void moveVirtual([in]String   virtualDir)

This method moves the uploaded file to the virtual directory on the server as specified in the argument.

Example:
(for moving files in virtual directory)

Html page:

         <HTML>  <HEAD>
        <TITLE>Multiple File Upload via iASP_Upload</TITLE>
        </HEAD>
        <BODY>
        <form enctype="multipart/form-data" method="post" action="sample2.asp">
        Enter filename to upload: <input type="file" name="file1"><br>
        Enter filename to upload: <input type="file" name="file2"><br>
        Enter filename to upload: <input type="file" name="file3"><br>
        <input type="submit">
        </form>
        </BODY>
        </HTML>

Script of 'sample2.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"
        For Each File in obj.Files
        File.moveVirtual "d:\virDir\" &  File.extractFileName
        Next
        %>



Method Signature:  void delete()

This method deletes the files on the Server.  Use this method when the uploaded files are either saved in the database or are copied to the desired location, and there is no need for these files on server hard disk.

Example:
(for deleting files)

Html page:

         <HTML>  <HEAD>
        <TITLE>Multiple File Upload via iASP_Upload</TITLE>
        </HEAD>
        <BODY>
        <form enctype="multipart/form-data" method="post" action="sample2.asp">
        Enter filename to upload: <input type="file" name="file1"><br>
        Enter filename to upload: <input type="file" name="file2"><br>
        Enter filename to upload: <input type="file" name="file3"><br>
        <input type="submit">
        </form>
        </BODY>
        </HTML>

Script of 'sample2.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.Files
        File.Copy "d:\archive\" &  File.extractFileName
        File.delete
        Next
        %>




Method Signature:  void toDatabase([in]String connectString, [in]String queryString)

This method  saves the browsed files into the database. The connectString is the proper Connection String in the format "DSN=DSNName;PWD=;UID=;" for the database, whereas the querystring is the proper insert or update query to be executed, with one '?' sign, which acts as the place holder for the file.

Example:
( for saving in Database)

Html page:

     <HTML>  <HEAD>
        <TITLE>Multiple File Save to the DataBase via iASP_Upload</TITLE>
        </HEAD>
        <BODY>
        <form enctype="multipart/form-data" method="post" action="sample2.asp">
        Enter filename to upload: <input type="file" name="file1"><br>
        Enter filename to upload: <input type="file" name="file2"><br>
        Enter filename to upload: <input type="file" name="file3"><br>
        <input type="submit">
        </form>
        </BODY>
        </HTML>

Script of 'sample2.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        count=0
        obj.save "c:\temp\"
        For Each File in obj.Files
            File.toDatabase  "data","insert into Blob(index,BlobF) values(count,?)"
            count=count+1
            File.delete
        Next
        %>




Method Signature:   String extractFileName()

This method returns the original name of the file uploaded.

Example:
(for retrieving the filenames)

Script of 'sample.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.Files
        File.Copy "d:\archive\" &  File.extractFileName
        File.delete    'deletes the current file
        Next
        %>



Method Signature:   String extractFolderName()

This method returns the back slash terminated uploaded path of the file.

Example:
(for retrieving the folder names)

Script of 'sample.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.files
        Response.Write  File.extractFolderName
        Next
        %>






DESCRIPTION OF PROPERTIES


Property Signature:   String getPath()

This is a read-only property. It returns the fully qualified path of the file on the server.

Example:
(for retrieving Path on server)

Script of 'sample.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.files
        Response.Write  File.getPath
        Next
        %>



Property Signature:   String getOriginalPath()

This is a read-only property. It method returns the fully qualified path of the file on the client.

Example:
(for retrieving Path on client)

Script of 'sample.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.files
        Response.Write  File.getOriginalPath
        Next
        %>



Property Signature:   int getOriginalSize()

This is a read-only property. It method returns the original size of the file on the client.

Example:
(for retrieving original size)

Script of 'sample.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.files
        Response.Write  File.getOriginalSize
        Next
        %>



Property Signature:   int getSize()

This is a read-only property. It method returns the uploaded size of the file, which may be different from the one on the client machine. The file size, for an upload, can be changed by using  setMaxSizeproperty on Uploadobject.

Example:
(for retrieving size)

Script of 'sample.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.files
        Response.Write  File.getSize
        Next
        %>



Property Signature:   String getName()

This is a read-only property. It method returns the value of the NAME attribute of this file's <INPUT TYPE=FILE> tag.

Example:
(for retrieving size)

Script of 'sample.asp':

        <%
        Set obj = Server.CreateObject("Persits.Upload")
        obj.save "c:\temp\"    'temporary saving
        For Each File in obj.files
        Response.Write  File.getName
        Next
        %>
 

 Back to UploadedFile     Back to Methods    Back to Properties    Back to iASP_Upload


If you require technical support please send complete details about the problem you are having to support@halcyonsoft.com.


Copyright © 1998-2000, Halcyon Software Inc. All rights reserved.