Solved

File name of email attachment

Posted on 2016-09-29
4
34 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 43

Assisted Solution

by:zephyr_hex (Megan)
zephyr_hex (Megan) earned 125 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 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 125 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 250 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

763 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