1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Gaps in File names

Discussion in 'Web Design & Development' started by Tony Beckett, Jul 17, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. Tony Beckett

    Tony Beckett Thread Starter

    Joined:
    Jul 17, 2007
    Messages:
    5
    Some web servers will accept gaps in .html and .jpg file names, some will not.

    Is this because some servers are running on unix/linux and some on Windows?
    If so which way round is it please?

    My reason for having gaps in file names - .jpgs in this case. Is that to do the minimum of editing when producing a web gallery of photographs is to give the .jpgs appropriate names. Such as "Jim and Joans wedding.jpg" - "Peter in London.jpg".

    If the server won't accept gaps then extra editing is needed.

    Is it regarded as "bad practice" to have gaps in file names?

    Thanks
    Tony
     
  2. jaymanson

    jaymanson

    Joined:
    Mar 18, 2007
    Messages:
    199
    Hi Tony,

    In a nutshell, spaces in web filenames cause problems! Not all the time, but sometimes! I wish I could tell you exactly when it will go wrong but the honest answer is that I don't actually know :) I was taught not to use spaces for web filenames when I learned web design so I've never encountered the problem.

    It's common to use an underscore in place of a space, like Peter_in_London.jpg for example. Your browser can fill in spaces sometimes with a hexidecimal value of %20 so you may have seen something like ../Peter%20in%20London.jpg in your address bar before, but you can't rely on that as you've found out already.

    I would bite the bullet and rename your files - at least you know then they'll work 100% of the time :)
     
  3. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    This is a quick script I wrote that once run will remove all spaces in file names in the current dir.

    PHP:
    <?php
    $handle 
    opendir('.');
    while (
    false !== ($readdir readdir($handle)))
    {
        if (!
    is_dir($readdir) && strpos($readdir' ') === TRUE)
            
    rename($readdirstr_replace(' ''%20'$readdir));
        else
            exit (
    "Nothing to fix!");
    }
    ?>
    I wrote that real quick but it should work.

    Replace '%20' with '+' or '_' or whatever you like. :)

    So each time you upload files just run that script.
     
  4. Tony Beckett

    Tony Beckett Thread Starter

    Joined:
    Jul 17, 2007
    Messages:
    5
    Thanks both of you for your help - looks like it will be no gaps in .jpg file names then....

    Regards

    Tony
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/596771

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice