Forums
This topic is locked
Removing invalid characters from file names
Posted 13 Jul 2006 13:10:01
1
has voted
13 Jul 2006 13:10:01 Kessa Thomas posted:
Hi All,I'm using asp pure upload 2.1.6 (Patrick and George will already be familiar with my enquires regarding that! <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> )
Anyway, I've noticed that the bit of code which is supposed to remove/replace any invalid characters doesn't seem to be working and so I wondered if someone would mind taking a look at the following:
<pre id=code><font face=courier size=2 id=code>
'Invalid characters
'Dollar sign ($)
'At sign (@)
'Angle brackets (< > ), brackets ([ ]), braces ({ }), and parentheses (( ))
<b>- Note additional space inserted to angle brackets to prevent smilies displaying in post</b>
'Colon ( : ) and semicolon ( ; )
<b>- Note additional space inserted to colon and semicolon to prevent smilies displaying in post</b>
'Equal sign (=)
'Caret sign (^)
'Pipe (vertical bar) (|)
'Asterisk (*)
'Exclamation point (!)
'Forward (/) and backward slash (\)
'Percent sign (%)
'Question mark (?)
'Ampersand (&
'Pound sign (£
'Plus sign (+)
'Hash (#)
'Wiggle (~)
'Misc (¬
'Left Speech mark (`)
'Comma (,)
'Space () - hopefully?
'Quotation mark (single or double) (' "
'Tab
Function pau_RemoveInvalidChars(str)
Dim newStr, ci, curChar, Invalid
Invalid = "$@<>[]{}():;=^|*!/\%?&£+#~¬`,' "" "
for ci = 1 to Len(str)
curChar = Mid(str,ci,1)
if InStr(Invalid, curChar) = 0 then
newStr = newStr & curChar
end if
next
pau_RemoveInvalidChars = Trim(newStr)
End Function
</font id=code></pre id=code>
Any ideas of how to fix this so that special characters are removed from the file name (I need to remove spaces too if possible)?
Thanks
Kessa
Edited by - kessa on 13 Jul 2006 13:12:03
Edited by - kessa on 13 Jul 2006 13:12:33