I would like to use this code on my website to allow simple file uploads
from clients. I would like to restrict the file types they can upload.
Can this be done? Any help appreciated.
Rod
http://www.thelazyadmin.com
ASP Code upload_file.asp
<% @Language=VBScr ipt %>
<HTML>
<HEAD>
<TITLE>FileUp Upload Simple Sample</TITLE>
</HEAD>
<BODY>
<%
Dim oFileUp
'--- Instantiate the FileUp object
Set oFileUp = Server.CreateOb ject("SoftArtis ans.FileUp")
'--- Set the Path property to the location you wish to temporarily
cache the incoming file before saving
oFileUp.Path = Server.MapPath( "uploads\da ta")
'--- Check if a file was selected (myFile is coming from the html
code)
'--- If so, continue processing
If Not oFileUp.Form("m yFile").IsEmpty Then
'--- Save the file
oFileUp.Form("m yFile").Save
'--- The file is saved, display a confirmation message
Response.Write ("<B>File saved successfully on the server
as:</B><BR>")
'--- The ServerName() property is the full path of the file where it
was saved on the server
Response.Write( oFileUp.Form("m yFile").ServerN ame)
Else
Response.Write( "Error: There was no file submitted for upload.")
End If
'--- Destroy objects
Set oFileUp = Nothing
%>
Webpage Code Upload_File_For m.html
</BODY>
</HTML>
Sample Upload Form (upload_file_fo rm.html)
<HTML>
<HEAD>
<TITLE>FileUp Simple Upload Sample</TITLE>
</HEAD>
<BODY>
<H3 ALIGN=center>&n bsp;</H3>
<H3 ALIGN=center>As p FileUp Upload Sample</H3>
<p ALIGN=center>&n bsp;</p>
<FORM ACTION="fileUp. asp" ENCTYPE="MULTIP ART/FORM-DATA"
METHOD="POST">
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP">En ter Filename:</TD>
<!--
Note: Notice this form element is of TYPE="FILE"
-->
<TD ALIGN="LEFT"><I NPUT TYPE="FILE" NAME="myFile" size="20"><BR>
Please click Browse to select a file.</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">& nbsp;</TD>
<TD ALIGN="LEFT"><I NPUT TYPE="SUBMIT" VALUE="Upload File"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>