
HTML form for uploading up to 3 files, which also contains
a text description field, and a multiple select control:
<HTML>
<BODY BGCOLOR="#FFFFFF">
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="Upload.asp">
<INPUT TYPE=FILE NAME="FILE1"><BR>
<INPUT TYPE=FILE NAME="FILE2"><BR>
<INPUT TYPE=FILE NAME="FILE3"><BR>
<INPUT TYPE=TEXT NAME="DESCRIPTION"><BR>
<SELECT NAME="CATEGORY" MULTIPLE>
<OPTION>Image
<OPTION>Text
<OPTION>Source Code
<OPTION>Archive
</SELECT><BR>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>
Corresponding Upload Script (Upload.asp):
<%
Set Upload = Server.CreateObject("Persits.Upload.1")
' Upload files
Upload.OverwriteFiles = False ' Generate unique names
Upload.SetMaxSize 1048576 ' Truncate files above 1MB
Upload.Save "c:\upload"
' Process all files received
For Each File in Upload.Files
' Save in the database as blob
File.ToDatabase "DSN=data;UID=sa;PWD=zzz;", _
"insert into mytable(blob) values(?)"
' Move to a different location
File.Copy "d:\archive\" & File.ExtractFileName
File.Delete
Next
' Display description field
Response.Write Upload.Form("Description") & "<BR>"
' Display all selected categories
For Each Item in Upload.Form
If Item.Name = "Category" Then
Response.Write Item.Value & "<BR>"
End If
Next
%>
Around 20 more code samples are included with the AspUpload evaluation download.
If you wish to learn how to use AspUpload to send email messages with file attachments,
download your copy of the free SMTP component AspEmail
which comes with a demo message-sending ASP application.
Copyright © 1999 Persits Software, Inc.
All Rights Reserved
Questions? Comments? Write us!
|