Well, erm, no. I'd store the filename, etc. as-is in the database, and then link it with urlencode() and you should be able to serve a file called "A non friendly name!" site.com/A%20non%20friendly.... and a modern webserver should be fine with that, and even most browsers will allow you to type site.com/A non friendly... without the url escaped characters and it will url escape them in the request. The only issue is that the urlencoded special characters are a lot uglier, which may or may not be a consideration for you. On Wed, Jun 3, 2009 at 12:39 PM, Skip Evans <skip@xxxxxxxxxxxxxxxxx> wrote: > You mean like this? This would work as a good file name to be on the server > and link to? > > $filename = urlencode($_FILES['myfile']['name']); > move_uploaded_file($_FILES['myfile']['tmp_name'], $filename); > > Think that would do the trick? > > Skip > > Eddie Drapkin wrote: > >> 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 <mailto: >> 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 <http://www.rgraph.net> - >> updated 23rd May) >> PHP mail: RMail (www.phpguru.org/rmail <http://www.phpguru.org/rmail>) >> PHP datagrid: RGrid (www.phpguru.org/rgrid >> <http://www.phpguru.org/rgrid>) >> PHP Template: RTemplate (www.phpguru.org/rtemplate >> <http://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 >> >> >> > -- > ==================================== > Skip Evans > Big Sky Penguin, LLC > 503 S Baldwin St, #1 > Madison WI 53703 > 608.250.2720 > http://bigskypenguin.com > ------------------------------------ > Those of you who believe in > telekinesis, raise my hand. > -- Kurt Vonnegut > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >