|
Uploading with SA-FileUp --
Simple Example
by David Wihl
SA-FileUp is an Active Server
component that allows users with a web browser to transmit files from their local hard disk to a Microsoft Internet
Information Server (IIS) web server.
Scripting the Upload
Your file upload script(s) will consist of two parts:
- An HTML form on the client
- An instance of the SA-FileUp object on the server
To try SA-FileUp, browse to select a small file on you system
and hit Upload File.
filename=/sa/test/uploadsimple.asp
<HTML><HEAD>
<TITLE>uploadsimple.asp by softwareartisans.com</TITLE>
</HEAD><body bgcolor="#FFFFFF">
<form enctype="multipart/form-data" method="post" action="uploadsimplerespond.asp">
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP">Filename:</TD>
<TD ALIGN="LEFT"><INPUT TYPE="FILE" NAME="FILE1">
</TD>
</TR>
<TR>
<TD ALIGN="RIGHT"> </TD>
<TD ALIGN="LEFT"><INPUT TYPE="SUBMIT" NAME="SUB1" VALUE="Upload File"></TD>
</TR>
<TR>
<TD ALIGN="RIGHT"> </TD>
<TD ALIGN="LEFT">
<B><I><SMALL>Note: if a button labeled "Browse..." does not appear, then your
browser does not support File Upload. For Internet Explorer 3.02 users, a
free add-on is available from Microsoft. If you <b>do not see a Browse... button</b>
<A HREF="http://www.microsoft.com/msdownload/ieplatform/iewin95/iewin95.asp" TARGET="_new">click here to go to Microsoft's Site and get your free file upload add-on</A>.
Select "Internet Explorer 3.02 File Upload Add-On for Windows 95 & NT".
</SMALL></I></B>
</TD>
</TR>
</TABLE>
</form>
</BODY></HTML>
The Form Definition
To enable file upload, include an INPUT tag of
<TYPE="FILE"> in your HTML form.
When using a form to upload files,
you must set the following attributes:
- The FORM tag must include the attribute ENCTYPE="multipart/form-data".
- The <INPUT TYPE="FILE"> must include the NAME attribute.
The Server-side Processing
The responder to the form will look like this:
filename=/sa/test/uploadsimplerespond.asp
<HTML><HEAD>
<TITLE>Uploadsimplerespond.asp by softwareartisans.com</TITLE>
</HEAD><BODY>
Thank you for uploading your file.<br>
<% Set upl = Server.CreateObject("SoftArtisans.FileUp")
upl.Path = Server.Mappath ("/upload/tests")
upl.SaveAs "upload.tst"%><BR>
Total Bytes Written: <%=upl.TotalBytes%>
</BODY></HTML>
To process the upload on the server,
The TotalBytes property contains the size in bytes of the uploaded file.
The directory on the web server must have Read, Write, and Delete
NTFS permissions for the anonymous or authenticated user. Otherwise, SA-FileUp will not be
able to write files into that directory. Talk to your web master about setting the appropriate permissions.
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|