We help IT Professionals succeed at work.
Get Started

Excluding file types in classic asp

Michael Ambech
on
134 Views
Last Modified: 2015-12-04
Hi all,

Messing around heavily with an upload feature for my customers. I got the renaming of the file to work thanks to some awesome help in this forum. However what was screwing that code up to begin with was my attempt to restrict filetypes to jpg, jpeg, gif & png files. So - Any great ideas on how to do that without messing up my beatiful working code? I have the name of file serverside and I have the extension, but can't figure out how to do anything with that information. I tried the feature found here, but that was what was messing things up in the first place.

Here's the code that I have so far:

<%
Set oFileUp = Server.CreateObject("SoftArtisans.FileUp")
oFileUp.Path = "server path..."
oFileUp.CreateNewFile = True
oFileUp.OverWriteFiles = True
'oFileUp.Maxbytes = 300

If Not oFileUp.Form("file1").IsEmpty Then
oFileUp.Form("file1").Save

If Err.Number <> 0 Then
Response.Write "<B>Error description:</B> " & Err.Description
Else
Response.Write ""
End If
Else
Response.Write "Error! There is no file chosen for upload!"
End If

strServerName = oFileUp.Form("file1").ServerName

dim fs,p
set fs=Server.CreateObject("Scripting.FileSystemObject")
e=(fs.GetExtensionName("" & strServerName & ""))
p=fs.getfilename("" & strServerName & "")
response.write(p)
response.write(e)
set fs=nothing


Set oFileUp = Nothing
%>

Open in new window

Comment
Watch Question
Developer
CERTIFIED EXPERT
Fellow
Top Expert 2013
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE