Forums

ASP

This topic is locked

File Type Restrictions

Posted 01 Jun 2007 15:08:56
1
has voted
01 Jun 2007 15:08:56 Lee Duncan posted:
Hi,

Having a bit of a problem with restricting the type of file users can upload to my site. When it comes to ASP it rather clueless so your help is much appreciated.

here is the code im using, what am i doing wrong?

<%

Set Upload = Server.CreateObject("Persits.Upload"

' Limit file size to 50000 bytes, throw an exception if file is larger
Upload.SetMaxSize 2000000, True

' Intercept all exceptions to display user-friendly error
On Error Resume Next

' Perform upload
Upload.Save "D:\uploads"

' restrict file types
For Each File in Upload.Save
Ext = UCase(Right(File.Path, 3))
If Ext <> "PDF" and Ext <> "DOC" Then
Response.Redirect "score-group.com/careers/upload-failed.asp"
File.Delete
End If
Next

' 8 is the number of "File too large" exception
If Err.Number = 8 Then
Response.Redirect "score-group.com/careers/upload/upload-failed.asp"
Else
If Err <> 0 Then
Response.Redirect "score-group.com/careers/upload/upload-failed.asp"
Else
Response.Redirect "score-group.com/careers/"
End If
End If

%>

Regards,
Lee

Reply to this topic