Hello
I would like to Remove Special characters in a filename before uploading the file or I would like to give a message that filename is not correct.
What i am trying below way it is form Handler.ashx
FileName = FileName.Trim.Replace(" ", "")
'Check if filename is valid
Dim regex As Regex = New Regex("[a-z][A-Z][.-_#[]?$%&(){}@][0-9]", RegexOptions.IgnoreCase)
Dim match As Match = regex.Match(Path.GetFileNameWithoutExtension(FileName)
If Not match.Success Then
context.Response.ContentType = "application/json"
context.Response.Write((New JavaScriptSerializer()).Serialize(New With {
.success = False,
.message = String.Format("{0} {1}",
FileName,
"File name is not valid please check and try again")}))
Exit Sub
End If