pteeter, please show an example of what a generated html table code looks like for your filenames with spaces.
Main Topics
Browse All TopicsI wrote a PHP based web front end for file upload & download a few years ago.
Outside our firewall, people connect to it via a browser or via WebDAV. They can download files, navigate thru nested directories, and upload files as well. Authentication is required to browse client directories, auth is tied to an Open LDAP directory.
Inside of our firewall, people connect to via SMB/CIFS or AFP file sharing.
Our external user population like the convenience of having a direct link to a file for download.
Our internal user population lacks the technical savvy to construct such direct links for delivery via email.
I am trying to code up a link/form that does the following -
1. shows up only for internal web connections (using HTTP_PC_REMOTE_ADDR in $_SERVER allows for this it appears)
2. addresses an email message with a URL to the file in the body of the message
Early tests showed this was quite possible using PHP/HTML.
Further coding to allow for files/folders with whitespace in the name have proved more challenging.
I've tried a variety of methods to accomplish this...
- php eregreplace " " with "%20"
- php urlencode
- now javascript document.write with either escape() or encodeURI()
When the source code for the web page generates, the URL is formatted properly - " " prints out as "%20". As soon as the mail client launches though, the URL loses the proper encoding.
My next attempt will involve setting the MIME type specifically I think.
The other option is to 'tell' my local users *NOT* to use spaces in file/folder names. Thing is I've been trying to get cooperation with such a policy for years...sigh.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This seemed to work for me:
<a href="mailto:?subject=file
I would recommend not creating HTML entities in the string and then pass it to urlencode as shown.
Outlook 2003, but I celebrated success too soon, Outlook 2003 doesn't translates the +'s into %20's and %20's are converted into spaces which break the HREF in the e-mail. It would seem you are left with not including spaces in these e-mails, one method to accomplish this is to use a script that references the filename with spaces as +'s:
<a href="mailto:?subject=file
Then in send.php you would urldecode() the file value and send the browser to that location.
Business Accounts
Answer for Membership
by: siliconbritPosted on 2007-11-19 at 17:03:16ID: 20316957
I have approached this problem myself. When fixed in one area something else in the chain fell apart.
I used four different solutions:
1) Generate tiny URL's for the documents to be downloaded. So you either use filesystem links or keep a hash table relating a small url to the actual document.
2) Zip the files and generate a name with no spaces.
3) Provide instructions on how to login and view the document through the browser rather than sending links in email.
4) Company wide policy to slaughter staff who put spaces in web-distributed documents.
Clearly the last one may be the least attractive (?!), but this is one of those issues that even Microsoft fails to solve for all recipients of it's Windows Live service marketing emails, including MS Outlook 2003 users. My vote is to workaround.