Forums
This topic is locked
Show hide based on file type using an IF/then
Posted 16 May 2009 17:40:33
1
has voted
16 May 2009 17:40:33 Ben Hyland posted:
i need to show or hide a file based on the filetype, example user can upload either JPG or PDF in the front end i need grab the file name and see if it is a jpg or pdf then filter it like below...<%If rsSaleDetail.Fields.Item("filed1".Value = ".JPG" Then %>
DO SOMETHING
<% else %>
<%If rsSaleDetail.Fields.Item("filed1".Value = ".pdf" Then %>
DO SOMETHING ELSE
<% END IF %>
<% END IF %>
any ideas?
Replies
Replied 23 May 2009 17:16:49
23 May 2009 17:16:49 Patrick Julicher replied:
Hi Ben,
Presuming it is ASP with VBScript, maybe this is helpful. Use the Function below to get the extension. After that a simple If GetExtension="PDF" Then DO SOMETHING will do the trick for you
Function GetExtension(FileName)
Dim DotPos
DotPos = InstrRev(FileName, "." )
If DotPos < Len(FileName) Then
GetExtension = Mid(FileName, DotPos + 1)
Else
GetExtension = ""
End If
End Function
Presuming it is ASP with VBScript, maybe this is helpful. Use the Function below to get the extension. After that a simple If GetExtension="PDF" Then DO SOMETHING will do the trick for you
Function GetExtension(FileName)
Dim DotPos
DotPos = InstrRev(FileName, "." )
If DotPos < Len(FileName) Then
GetExtension = Mid(FileName, DotPos + 1)
Else
GetExtension = ""
End If
End Function