Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Getting rid of space in filename

Posted on 2007-07-27
4
Medium Priority
?
794 Views
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)
0
Comment
Question by:rohgan
  • 3
4 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 19583853
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.

bol
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 2000 total points
ID: 19583862
For example if the file name is ...

my file name.txt

then you would need ...

my%20file%20name.txt

bol
0
 
LVL 48

Expert Comment

by:hernst42
ID: 19583955
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 http://de2.php.net/urlencode
0
 
LVL 54

Expert Comment

by:b0lsc0tt
ID: 19585328
Thanks for the grade, the points and the fun question.  I'm glad I could help.

bol
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 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