?
Solved

File name of email attachment

Posted on 2016-09-29
4
Medium Priority
?
46 Views
Last Modified: 2016-09-29
I build the filename of an email attachment based on a "property description".

In a particular case, the property description is #68 Residence.

That is passed as a $_GET variable to the emailing routine; I'm guessing that either # is not allowed in a file name (or more likely) # does not get properly passed in the query string.

Should I just replace # with # in the query string? Not sure if that stuff in a file name would work.

Or maybe better yet, I could probably just throw away the #, not needed in this case, but there are probably other special characters.

Suggested solution?
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 44

Assisted Solution

by:zephyr_hex (Megan)
zephyr_hex (Megan) earned 500 total points
ID: 41822397
If you're adding the $_GET parameter using PHP, you should use urlencode() to properly encode your url.

If you're using something other than PHP, please let us know how that parameter is added to the url.
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 41822398
Get rid of any version of '#', it is not a legal part of the file name in a query string.  It is used to locate a named or id'd anchor on a page.  In addition, any spaces will be changed to %20.  It is best not to have spaces in the first place.
0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 1000 total points
ID: 41822526
When I deal with filenames, I usually replace any non-valid characters with underscores:

$file = "My Residence @ #68 main st.";
$file  = preg_replace("/[^a-zA-Z0-9]/","_",$file);
// $file is now "My_Residence___68_main_st_";

You can additionally trim the _ down a little bit (consolidate multiple ___ to just one _, etc), but that should ensure that all filenames will be valid.
0
 

Author Closing Comment

by:Richard Korts
ID: 41822615
Thank you, I got all of it I & understand.

Richard
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

650 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