|
Posted by My Pet Programmer on 12/28/07 16:32
jodleren said:
> On Dec 28, 5:41 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
> escomposlinux.-.punto.-.org> wrote:
>> jodleren wrote:
>>> On Dec 28, 5:20 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
>>> escomposlinux.-.punto.-.org> wrote:
>>>> jodleren wrote:
>>>>> To check for invalid characters in a filename
>>>> Escape the filename, then.
>>> Sorry, I dont get this one.
>> OK... why do you need to check for invalid characters in a filename?
>>
>> In other words, where could a filename with "strange" characters cause
>> damage to your system?
>
> Windows based systems do not allow certain characters. I need to check
> for them, _even_ that my server can handle them, I still have to think
> of the user downloading a file etc....
Been there, definitely.
preg_match('/^([a-zA-Z]\:)(\\[^\\/:*?<>"|]*(?<![
]))*(\.[a-zA-Z]{2,6})$/', $filename);
That one should only match valid filenames.
~A!
--
Anthony Levensalor
anthony@mypetprogrammer.com
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. - Albert Einstein
[Back to original message]
|