Why not just urlencode() the filename? (and suggest people use a URL shortening service and/or provide one) On Wed, Jun 3, 2009 at 12:31 PM, Richard Heyes <richard@xxxxxxx> wrote: > Hi, > > > I have a file uploader module that allows users to upload documents and > of > > course people are using all kinds of file names that are not web > friendly. > > > > I guess the best solution is to replace any non alphanumeric with maybe > '_' > > the underscore? How does that sound? > > > > Unfortunately, after 20+ years of coding I cannot get my brain around > > regular expressions to any decent level of proficiency, I know sad. > > > > I'd like to hear other solutions for this problem, I am thinking of a > regexp > > that replaces special chars with the underscore; sounds pretty robust and > > globally acceptable? > > I replace any non alpha chat with a hyphen, then replace two or more > hyphens with one. Simple, but I would also include the date so that > naming clashes are less likely (if it's applicable). So you might end > up with something similar to this: > > /product/2009/06/03/24ct-gold-earrings > > Or if using the date is not applicable, you could get something like this: > > /product/24ct-gold-earrings > > -- > Richard Heyes > HTML5 graphing: RGraph (www.rgraph.net - updated 23rd May) > PHP mail: RMail (www.phpguru.org/rmail) > PHP datagrid: RGrid (www.phpguru.org/rgrid) > PHP Template: RTemplate (www.phpguru.org/rtemplate) > PHP SMTP: http://www.phpguru.org/smtp > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >