Getting rid of space in filename

Posted on 2007-07-27
Last Modified: 2012-06-21
I have a variable storing a filename.

When I create a href link using the variable it works ok. However it fails in firefox if the filename contains a space. How can I make firefox read the full filename which contains space (file is stored on server with the  name that contains space)
Question by:rohgan
    LVL 54

    Expert Comment

    You need to replace the space with %20 when it is in the URL.  If you use a server language you might be able to use a function to automatically do this.  That function would probably make other characters safe for the URL too.

    Let me know if you have a question.  If you need help doing this then let me know what language and code you are using and I can help with the replace.

    LVL 54

    Accepted Solution

    For example if the file name is ...

    my file name.txt

    then you would need ...


    LVL 48

    Expert Comment

    Do you use quotes around the value for the href like:
    <a href="filename with space.bin"> or do you use <a href=filename with space.bin> which will break the name. User urlencode to transform the fielname into a valid encoding
    LVL 54

    Expert Comment

    Thanks for the grade, the points and the fun question.  I'm glad I could help.


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now