A Windows filename can’t use any of the following characters:
/ : * ? ” <> |
So, turn that into a regular expression and drop it into preg_replace. I don’t remember exactly which characters have to be escaped so you may have to tweak this a little, but something like:
$filename = preg_replace(“/[//:*?"<>|]/”, “”, $filename);
Basically what you need to do is create an array of the characters you do not want in the file, then loop through the filename one character at a time. Then use the function stripos to check if the current character is in the not allowable list if it is return false. If you have gone through all the characters in the file then you return true.
A Windows filename can’t use any of the following characters:
/ : * ? ” <> |
So, turn that into a regular expression and drop it into preg_replace. I don’t remember exactly which characters have to be escaped so you may have to tweak this a little, but something like:
$filename = preg_replace(“/[//:*?"<>|]/”, “”, $filename);
Basically what you need to do is create an array of the characters you do not want in the file, then loop through the filename one character at a time. Then use the function stripos to check if the current character is in the not allowable list if it is return false. If you have gone through all the characters in the file then you return true.