Hi all
I've built this photo site - www.ingridvekemans.com - from PHP and Javascript. The images are stored in a directory called 'Portfolio' and their info is stored in the database. My question is, how bad is it that the image names contain spaces? For example, an image name might be 'Two lions hunting.jpg'. It all works fine, but should it be 'Two_lions_hunting.jpg'? Or with hyphens?
Thanks!
Page 1 of 1
image naming (with spaces?)
#2
Posted 18 March 2010 - 09:12 AM
Spaces are not a good idea, but you can use a PHP function to fill or ignore the spaces. Do a search as I'm not sure which it is.
This might help
http://bytes.com/top...itespace-string
This might help
http://bytes.com/top...itespace-string
#3
Posted 18 March 2010 - 09:37 AM
From a practical perspective it usually won't make a difference. However your pages may fail to validate.
If for some reason you are unable to use hyphens or underscores instead of spaces when naming the files, you can use PHP's rawurlencode function to replace the spaces with %20, e.g:
<?php echo rawurlencode('my file name.jpg'); ?>
outputs:
my%20file%20name.jpg
If for some reason you are unable to use hyphens or underscores instead of spaces when naming the files, you can use PHP's rawurlencode function to replace the spaces with %20, e.g:
<?php echo rawurlencode('my file name.jpg'); ?>
outputs:
my%20file%20name.jpg
#4
Posted 18 March 2010 - 10:56 AM
thanks both
It does all work at the moment, but I want it to be as good as possible. I think a few hours' PHP can put in underscores, but before I do that, can I ask one more question? The site has only been online for a few weeks and Google's image bot hasn't swung by yet. If and when it does, do you know if there's any advantage/disadvantage to having spaces or underscores? I've read through the Google info but haven't found anything related...
Gordon.
It does all work at the moment, but I want it to be as good as possible. I think a few hours' PHP can put in underscores, but before I do that, can I ask one more question? The site has only been online for a few weeks and Google's image bot hasn't swung by yet. If and when it does, do you know if there's any advantage/disadvantage to having spaces or underscores? I've read through the Google info but haven't found anything related...
Gordon.
- ← Instant Error Message Feedback on PHP Contact Form?
- Server Side (PHP, Databases, ASP.NET, etc)
- Page shows php code! →
Share this topic:
Page 1 of 1
Help
















