[PHP] Web friendly file names

2009-06-03 Thread Skip Evans
Hey all, 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,

Re: [PHP] Web friendly file names

2009-06-03 Thread Richard Heyes
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

Re: [PHP] Web friendly file names

2009-06-03 Thread Eddie Drapkin
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 rich...@php.net wrote: Hi, I have a file uploader module that allows users to upload documents and of course people are using all

Re: [PHP] Web friendly file names

2009-06-03 Thread Skip Evans
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

Re: [PHP] Web friendly file names

2009-06-03 Thread Eddie Drapkin
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

Re: [PHP] Web friendly file names

2009-06-03 Thread Skip Evans
Oh, of course that makes sense, and I suppose the PHP move_uploaded_file() function has no problem with weird and crappy file names? Skip Eddie Drapkin wrote: 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

Re: [PHP] Web friendly file names

2009-06-03 Thread Eddie Drapkin
As far as I know it will only bug out when the host filesystem would bug out, ie UTF-16 characters tend to explode on my linux setup that I develop on, and PHP's file handlign doesn't like them, but then again neither does the filesystem. Stuff like Some silly name! YAY# work fine, on the

Re: [PHP] Web friendly file names

2009-06-03 Thread Bastien Koert
On Wed, Jun 3, 2009 at 1:18 PM, Eddie Drapkin oorza...@gmail.com wrote: As far as I know it will only bug out when the host filesystem would bug out, ie UTF-16 characters tend to explode on my linux setup that I develop on, and PHP's file handlign doesn't like them, but then again neither does

Re: [PHP] Web friendly file names

2009-06-03 Thread Paul M Foster
(Sorry, I hit the wrong button and sent the reply only to Skip.) On Wed, Jun 03, 2009 at 11:18:57AM -0500, Skip Evans wrote: Hey all, 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

Re: [PHP] Web friendly file names

2009-06-03 Thread Eric Butera
On Wed, Jun 3, 2009 at 2:29 PM, Paul M Foster pa...@quillandmouse.com wrote: (Sorry, I hit the wrong button and sent the reply only to Skip.) On Wed, Jun 03, 2009 at 11:18:57AM -0500, Skip Evans wrote: Hey all, I have a file uploader module that allows users to upload documents and of