home *** CD-ROM | disk | FTP | other *** search
- <%
- ' This file is provided as part of ASP Power Widgets Samples
- '
- ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT
- ' WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
- ' INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
- ' OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
- ' PURPOSE.
-
- ' Copyright 1997-1998. All rights reserved.
- ' Dalun Software Inc. ASP Power Widgets
- ' http://dalun.com
- ' mail: sales@dalun.com
- ' mail: techsupport@dalun.com
- ' if you have any suggestions or requirements, please write to us.
- ' Please set your editor's TAB as 4.
- ' Revisions:
- ' 1.00 Initial release
- ' 1.10 Added reading form items.
- ' 1.11 Added oUpload.Form, added oUpload.UploadedFiles(i).FormName
- %>
-
- <HTML><HEAD><TITLE>File Upload Test</TITLE></HEAD>
-
- <BODY TEXT="gray" LINK="silver" VLINK="silver" BGCOLOR="Gray">
- <BR><BR>
-
- <CENTER>
- <FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver">
- <%
-
- if Request.querystring("Status") = 1 then
- Set oUpload = Server.CreateObject("ASPPW.upload")
- oUpload.UserDiskQuota= 2 * 1024 * 1024
- oUpload.RejectEmptyExtension = true
- oUpload.FileExtensionList "*","txt", "gif" ,"jpg" 'remove '*', if you don't allow all types
- oUpload.UpLoadPath = server.mappath("/") + "\test"
- i=oUpload.Upload
- Select Case i
- case 1
- sMsg = "File uploading ends normally."
- Case -4
- sMsg = "User's Disk Quota full. At least one file hasn't been saved."
- Case -5
- sMsg = "Path on server for uploading not found or invalid."
- Case -6
- sMsg = "File type for uploading is not allowed. At least one file hasn't been saved."
- Case -7
- sMsg = "Uploading exception."
- Case -8
- sMsg = "File access failure."
-
- case else
- sMsg = "Exception. Error Code is: " & cstr(i) & "."
- End Select
-
- response.write sMsg + "<br>"
- response.write cstr(oUpload.NumofUploadedFiles) + " file(s) uploaded. <br>"
-
- if oUpload.GetLastErrNum <> 0 then
- response.write oUpload.GetLastErrDescription
- end if
-
-
- set oFiles = oUpload.UploadedFiles 'return a Collection
- 'response.write oFiles.count 'Sample operation to a collection
- 'response.write oFiles.item(1) 'Sample operation to a collection
-
- set oForm = oUpload.Form 'return a Collection
-
- %>
-
- <table width="66%" border="1">
- <% for each file in oFiles %>
- <tr>
- <td><FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver"><%=file.filename%></font></td>
- <td><FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver"><%=file.filelen%></font></td>
- <td><FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver"><%=file.formname%></font></td>
- <td><FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver"><%=oform(file.formname)%></font></td>
- </tr>
- <% next %></FONT>
- </table>
- <%
- set oFiles = nothing
- set oForm = nothing
- %>
-
- <%
- set oFormItems = oUpload.FormItems 'return a Collection
- 'Note: oFormItems is another way to fetch form items.
- %>
- <p><FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver">
- Demonstration of fetching form items:</font>
-
- <table width="66%" border="1">
- <% for each item in oFormItems %>
- <tr>
- <td><FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver"><%=item.name%></font></td>
- <td><FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver"><%=item.value%></font></td>
- </tr>
- <% next %></FONT>
- </table>
- <%
- set oFormItems = nothing
- %>
-
- <%
- set oUpload = nothing
- end if
- %>
- </font>
-
- <FORM NAME=up ACTION="fupload.asp?Status=1" METHOD="POST" ENCTYPE="multipart/form-data">
-
- <!-- You can specify the filenames for uploaded files as below
- ServerName1 ...99
- <FORM NAME=up ACTION="fupload.asp?Status=1&ServerName1='aa 1.gif'&ServerName2='bb 2.gif'" METHOD="POST" ENCTYPE="multipart/form-data">
- -->
- <TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 BGCOLOR="Gray" WIDTH=400>
-
- <TR><TD>
- <FONT FACE ="Verdana, Arial, Helvetica" SIZE="2" COLOR="silver">
- UpLoad Test<BR>
- </FONT><BR> </TR></TD><TR>
- <TD BGCOLOR="Silver" WIDTH=400>
- <FONT SIZE="1" COLOR="gray" FACE="Verdana, Arial, Helvetica">
- UPLOAD FILE</FONT>
- </TD></TR>
-
- <!-- Remove below form item if you don't need it. -->
- <TR><TD>
- <INPUT TYPE=HIDDEN SIZE=36 NAME="Org_Code" VALUE="Research Dept.">
- </TD></TR>
- <!-- Remove above form item if you don't need it. -->
-
- <!-- Remove below form item if you don't need it. -->
- <TR><TD>
- <INPUT TYPE=HIDDEN SIZE=36 NAME="uplfile1" VALUE="From Research Dept.">
- </TD></TR>
- <!-- Remove above form item if you don't need it. -->
-
- <!-- Remove below form item if you don't need it. -->
- <TR><TD>
- <INPUT TYPE=HIDDEN SIZE=36 NAME="uplfile2" VALUE="From Development Dept.">
- </TD></TR>
- <!-- Remove above form item if you don't need it. -->
-
- <TR><TD>
- <INPUT TYPE=FILE SIZE=36 NAME="uplfile1"> <!-- ServerName1 -->
- </TD></TR>
-
- <TR><TD>
- <INPUT TYPE=FILE SIZE=36 NAME="uplfile2"> <!-- ServerName2 -->
- </TD></TR>
-
- <!-- You can add more if you want to upload more files at a single time -->
-
- <TR><TD ALIGN="RIGHT">
- <FONT SIZE="1" COLOR="silver" FACE="Verdana, Arial, Helvetica">Dalun Software, Inc.
- <B>[<A HREF="javascript:document.up.submit();"><B> S U B M I T </B></A>]</FONT>
- </TD></TR>
- </TABLE></FORM>
-
- </CENTER>
- </BODY></HTML>
-