I have to filter filenames to match only image (png,jpg,gif,bmp) files, is possible to make a such regex or do I have to have different regex for every file type? It also cannot contain path like ../../ or /var/app/filename.exe etc.
-
From where are you getting this file paths? From browser? From FileDialog?Harry Joy– Harry Joy2011-08-18 05:43:31 +00:00Commented Aug 18, 2011 at 5:43
-
So you want to make validation in javascript?Harry Joy– Harry Joy2011-08-18 05:52:41 +00:00Commented Aug 18, 2011 at 5:52
-
No, in Java server side.newbie– newbie2011-08-18 06:23:25 +00:00Commented Aug 18, 2011 at 6:23
-
Request is made like this myserverurl?filename=imagefilename.pngnewbie– newbie2011-08-18 06:24:28 +00:00Commented Aug 18, 2011 at 6:24
Add a comment
|
4 Answers
Link:
I hope you find it useful.
2 Comments
newbie
I have to mention that that code must be edited if you don't want to allow paths in filenames. I used ([\w]+(\.(?i)(jpg|png|gif|bmp))$) , which means only letters and numbers are allowed in filename.
alexander
It might be useful to provide any code, with some explanation. Imagine the blog does not exist any more.