views:

330

answers:

8

I've read all over the place NOT to use spaces in file names intended for use on the Web, e.g. URLs.

I don't understand what's wrong with using "%20" to replace them when referring to the name in my code. It seems more appropriate to use this replacement because I'm then preserving semantic meaning of my file name.

?

+26  A: 

first off, it is not that you can't it is that you shouldn't. It is not best practice to have spaces in your file names, it just complicates things, period.

second, it is harder for someone to manually type in the address if they wish.

i.e. "hey go to my site and get my resume at" www.... /my%20resume

just my $0.02

Robert Greiner
+23  A: 

It's ugly. Aesthetics do matter for anything a user sees.

Kristopher Johnson
I wish I could up vote this one twice. Unfortunately, many developers treat aesthetics the same way they treat security: something to be tacked on after all the "real" work is done, almost as an afterthought. Usually, that ends poorly. Treating aesthetics (and security) as a first class concern is often the difference between great and mediocre software.
William Brendel
@ William Brendel: Funny, I think the opposite is true. You as a developer will probably notice, I doubt that the average customer will, though
Treb
@Treb: Au contraire. I once banged out a very simple RapidShare-style internal app for a company I was at, and my initial choice to leave spaces from the filenames in the URLs led to all sorts of confusion as to what this mysterious %20 business was all about.
Chuck
@Treb: Have to agree with William. On projects I've demo'd where the UI lacked polish, customers were too hung up on things like font sizes and control placement to give me feedback on the functional requirements. On the other hand, when the project was designed with aesthetics in mind start-to-finish, the customers are able to focus on functional requirements and give better feedback.
Adam Bellaire
@Treb: The funny thing about aesthetics is that it matters without anyone even realizing it--insidious really! Users might not come right out and say, "Gee! I think I'll use this website because it's more aesthetically pleasing!", but you can be sure they are aware of it, at some level. Clean URLs might be a poor example. A website with a harsh, clashing color scheme might be a better one. Aesthetics extends far beyond the outward appearance of a website. It extends to the functionality, and rest assured, users do notice and act on that.
William Brendel
+3  A: 

They are not very human readable (memorable or typeable) if they show up in URLs and if they are not properly escaped you can have line breaks in things like email.

What's your reason for using them (instead of PascalCase or Blog-Permalink-style) in the first place?

Cade Roux
My reason: I want to preserve a file's name for distributing it over the Web. The most important thing here is the file because that's the thing the user cares about in this case.I posted here so I could get the lowdown on this business because the tutorials I've read don't explain the WHY so much as the DON'T DO THIS.
Pup
+2  A: 

I like to make things as simple as possible for user usability and developer code readability. One way to do that is to not use spaces like that.

Troggy
A: 

Use something that's more human readable, such as file-name.html or fileName.html. This will be more human readable and easier to work with.

Zack
+31  A: 

It's user friendly to have readable URLs.

For example, this page could have been:

http://stackoverflow.com/questions/1093611/why%20shouldnt%20i%20use%20spaces%20in%20file%20names%20when%20i%20can%20use%20a%20code%20equivalent

Not nearly as readable at first glance.

Will Eddins
An simple example is worth a thousand complicated words! I'd give you 10 votes if I could. :-)
Cerebrus
brilliant example
Robert Greiner
Best answer of the lot. Perfect illustration.
ceejayoz
+1 really awesome example! :-)
Zack
+3  A: 

Another issue, as mentioned in the "Browser security handbook", some browsers do decode such %20 into whitespace, but some not. This lead to different look of the same link in different browsers.

Alex Pavlov
A: 

You could just create a download page for your users with a list of all the files. If you force the download on the link the user will never have to type the %20

Tony Borf