?
Solved

File name of email attachment

Posted on 2016-09-29
4
Medium Priority
?
41 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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 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)
Suggested Courses

765 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