*** matt wrote/escribió (Tue, 11 Jan 2005 21:41:50 +1000):
I have an upload script for a photo and a caption. It all goes pear
shaped when I upload a character like ' " or / \ |
Is there anyway I can parse through the filename when submitting the
form and remove any illegal characters like this???
Usage: mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit] )
Purpose: Perform a regular expression search and replace
Availability: PHP 3>= 3.0.9, PHP 4
Rather than removing a set of invalid chars, I suggest you remove
everything except a set of valid chars.
$foo=preg_replace('/[^0-9a-z ]+/i', '', $foo); // Code not tested
$foo=preg_replace('/[^\w\d\s]+/i', '', $foo); // Code not tested
--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--