Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP File Upload - Limit File Types?

Reply
Thread Tools

ASP File Upload - Limit File Types?

 
 
lazyadmin
Guest
Posts: n/a
 
      01-07-2005
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=VBScript %>
<HTML>
<HEAD>
<TITLE>FileUp Upload Simple Sample</TITLE>
</HEAD>
<BODY>
<%
Dim oFileUp
'--- Instantiate the FileUp object
Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
'--- Set the Path property to the location you wish to temporarily
cache the incoming file before saving
oFileUp.Path = Server.MapPath("uploads\data")
'--- Check if a file was selected (myFile is coming from the html
code)
'--- If so, continue processing
If Not oFileUp.Form("myFile").IsEmpty Then
'--- Save the file
oFileUp.Form("myFile").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("myFile").ServerName)
Else
Response.Write("Error: There was no file submitted for upload.")
End If
'--- Destroy objects
Set oFileUp = Nothing
%>


Webpage Code Upload_File_Form.html

</BODY>
</HTML>
Sample Upload Form (upload_file_form.html)
<HTML>
<HEAD>
<TITLE>FileUp Simple Upload Sample</TITLE>
</HEAD>
<BODY>
<H3 ALIGN=center>&nbsp;</H3>
<H3 ALIGN=center>Asp FileUp Upload Sample</H3>
<p ALIGN=center>&nbsp;</p>
<FORM ACTION="fileUp.asp" ENCTYPE="MULTIPART/FORM-DATA"
METHOD="POST">
<TABLE WIDTH="100%">
<TR>
<TD ALIGN="RIGHT" VALIGN="TOP">Enter Filename:</TD>
<!--
Note: Notice this form element is of TYPE="FILE"
-->
<TD ALIGN="LEFT"><INPUT 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"><INPUT TYPE="SUBMIT" VALUE="Upload File"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>


 
Reply With Quote
 
 
 
 
lazyadmin
Guest
Posts: n/a
 
      01-07-2005
Well I guess I answered myself

http://www.learnasp.com/learn/uploadlimitsize.asp

Rod
http://www.thelazyadmin.com


"lazyadmin" <(E-Mail Removed)> wrote in message
news:%23wrXz%(E-Mail Removed)...
>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=VBScript %>
> <HTML>
> <HEAD>
> <TITLE>FileUp Upload Simple Sample</TITLE>
> </HEAD>
> <BODY>
> <%
> Dim oFileUp
> '--- Instantiate the FileUp object
> Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
> '--- Set the Path property to the location you wish to temporarily
> cache the incoming file before saving
> oFileUp.Path = Server.MapPath("uploads\data")
> '--- Check if a file was selected (myFile is coming from the html
> code)
> '--- If so, continue processing
> If Not oFileUp.Form("myFile").IsEmpty Then
> '--- Save the file
> oFileUp.Form("myFile").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("myFile").ServerName)
> Else
> Response.Write("Error: There was no file submitted for upload.")
> End If
> '--- Destroy objects
> Set oFileUp = Nothing
> %>
>
>
> Webpage Code Upload_File_Form.html
>
> </BODY>
> </HTML>
> Sample Upload Form (upload_file_form.html)
> <HTML>
> <HEAD>
> <TITLE>FileUp Simple Upload Sample</TITLE>
> </HEAD>
> <BODY>
> <H3 ALIGN=center>&nbsp;</H3>
> <H3 ALIGN=center>Asp FileUp Upload Sample</H3>
> <p ALIGN=center>&nbsp;</p>
> <FORM ACTION="fileUp.asp" ENCTYPE="MULTIPART/FORM-DATA"
> METHOD="POST">
> <TABLE WIDTH="100%">
> <TR>
> <TD ALIGN="RIGHT" VALIGN="TOP">Enter Filename:</TD>
> <!--
> Note: Notice this form element is of TYPE="FILE"
> -->
> <TD ALIGN="LEFT"><INPUT 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"><INPUT TYPE="SUBMIT" VALUE="Upload File"></TD>
> </TR>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload a file without file Upload control - ASP.Net =?Utf-8?B?U2FyYXY=?= ASP .Net 3 08-03-2005 01:09 AM
c program, file size limit, how to solve? 2G bytes limit. guru.slt@gmail.com C++ 1 06-27-2005 11:05 PM
File upload limit handleing MS News \(MS ILM\) ASP .Net 4 08-20-2004 05:55 AM
graceful file upload limit error? Tom Kaminski [MVP] ASP .Net 6 07-20-2004 06:53 PM
file upload size limit Vicky ASP .Net 1 02-11-2004 08:31 AM



Advertisments