> In my document management application, I have recently
> run into a problem.  I have some documents which were
> named with pound signs in their name "interview with
> john smith #1.doc" for instance.  When I link to this
> file name, the link doesn't work:
> 
> <a href="/documents/interview with john smith
> #1.doc">Download file a</a>
> 
>   It will generate a 404 file not found.  So the
> question is, why does this happen? Is this a document
> encoding issue?  Can anyone suggest a solution aside
> from just renaming the file before its saved?

The # character is a URL metacharacter - it means something specific within
the context of a URL. If you want to use a metacharacter as a literal
character, you need to escape the metacharacter. If you're building a CF
page, this is easy to do with the URLEncodedFormat function:

<cfoutput>
<a href="#URLEncodedFormat("/documents/interview with john smith
#1.doc")#">Download file a</a>
</cfoutput>

If you're not building a CF page, you will need to manually escape the
characters with their matching escape sequences. The URL encoding sequence
for "#" is "%23": 

http://www.w3schools.com/html/html_ref_urlencode.asp

For that matter, spaces are invalid characters within a URL as well,
although most modern browsers will automatically escape them.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized 
instruction at our training centers in Washington DC, Atlanta, 
Chicago, Baltimore, Northern Virginia, or on-site at your location. 
Visit http://training.figleaf.com/ for more information!


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:212401
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to